PDA

View Full Version : Bounced email


Mr Blek
30th June 2007, 16:09
Any bounced email returns to wwwrun@hostname.domain.com for all the hosted sites. How can I change it so it returns back to the originator?

In VBulletin I can do this by using SMTP for sending emails. The problem seems to be with those sites using the php mail function.

Using SMTP:

Return-Path: <webmaster@hostedsite.com>

Using php mail:

Return-Path: <wwwrun@hostname.domain.com>

till
30th June 2007, 18:42
The PHP scripts must set the correct from and return-path parameters in the php mail function as additional headers:

http://www.php.net/manual/en/function.mail.php

Mr Blek
1st July 2007, 17:33
If I do it from VBulletin I need to send the -f parameter to sendmail.

On the VBulletin diagnostic page it says


Pertinent PHP Settings
SMTP: localhost
sendmail_from: None
sendmail_path: /usr/sbin/sendmail -t -i

Results
The mailing function returned an error while trying to send the mail.
Check your mail server to ensure it is configured correctly to allow PHP to send mail from it. You should also check your mail server's error log for more diagnostic information.


I can't see no errors in /var/log/mail*

Any ideas?

Mr Blek
2nd July 2007, 00:52
If I use the following code without the -f option:

<?php

// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
mail('user@domain.com', 'My Subject', $message);

?>


The email is sent and the mail log outputs the following:


Jul 2 02:01:55 europa postfix/pickup[28530]: E7383B583C9: uid=30 from=<wwwrun>
Jul 2 02:01:55 europa postfix/cleanup[29251]: E7383B583C9: message-id=<20070702000155.E7383B583C9@europa.mydomain.com>
Jul 2 02:01:56 europa postfix/qmgr[25689]: E7383B583C9: from=<wwwrun@europa.mydomain.com>, size=345, nrcpt=1 (queue active)
Jul 2 02:01:57 europa postfix/smtp[29254]: E7383B583C9: to=<user@gmailcom>, relay=gmail-smtp-in.l.google.com[209.85.129.27]:25, delay=2, delays=0.14/0/1.4/0.4, dsn=2.0.0, status=sent (250 2.0.0 OK 1183334517 g28si14191589fkg)
Jul 2 02:01:57 europa postfix/qmgr[25689]: E7383B583C9: removed


However, if I now attempt sending an email with the -f option:



<?php

// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

$returnval = mail('user@domain.com', 'the subject', 'the message', null,
'-f webmaster@domain.com');
?>

No email is sent and nothing gets written to any of the mail logs (messages,mail, mail.err, mail.info, mail.warn). The variable $returnval is empty.

till
2nd July 2007, 10:35
Please use this example and not the sendmail parameters:

<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

Mr Blek
2nd July 2007, 11:46
Please use this example and not the sendmail parameters:

<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>


That sent the email fine, but the return path is still wwwrun@europa.domain.com. It should be the sender. Even if I stick in Return-Path: webmaster@domain.com it still gets overwritten with the wwwrun one.

Mr Blek
2nd July 2007, 17:26
Fixed it. Seems you can't use the -f param with php safe mode