php.ini setting - sendmail_from

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
holografix
Forum Newbie
Posts: 1
Joined: Tue Feb 19, 2008 8:04 am

php.ini setting - sendmail_from

Post by holografix »

Hi

The server i'm using runs Windows 2003 Server and a smtp server to send email.

Without Swift I have to do ini_set("sendmail_from", "xpto@mydomain.com") - a valid email account - in every script I send email.

Now I need to do a "tell-a-friend" script where the user submit a form with his name, email, a short message and his friend's name and email.

Code: Select all

 
ini_set("sendmail_from", "xpto@mydomain.com");
 
$headers  = 'MIME-Version: 1.0\r\n';
$headers .= 'Content-type: text/html; charset=iso-8859-1; format=flowed\r\n';
 
$headers = 'From: ' . $YourName . '<' . $YourEmail . '>\r\n';
mail($FriendEmail, $subject, $emailMessage, $headers);
 
This works fine and the friend's user can reply him.

But this, with Swift mailer does not send the messages.

Code: Select all

 
require_once $swiftPath . "Swift.php";
require_once $swiftPath . "Swift/Connection/SMTP.php";
 
$swift = new Swift(new Swift_Connection_SMTP("localhost", 25));
 
$subject = $YourName . " sent you an invite";
$message = new Swift_Message($subject, $emailMessage, "text/html");
 
$swift->send($message, $FriendEmail, new Swift_Address($YourEmail, $YourName));
 
If I replace $YourEmail var with xpto@mydomain.com it works but this prevents "friend" to reply to the user who invited him.

Is there a way/workaround to solve the problem?

Best regards
holo
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: php.ini setting - sendmail_from

Post by Chris Corbyn »

Sounds like that SMTP server is not for sending outgoing mail.

Have you double-checked the settings with your web host?
Post Reply