Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

In my postfix log I have the following when I send e-mail from a PHP based web site:

Feb 11 11:52:04 cp5 postfix/qmgr[6007]: 93C6E79C4D1: from=|www-data@domain.com|, size=3266, nrcpt=1 (queue active)

(I substituted | for smaller-than / greater-than signs.)

The problem with the above is that I need to control the "FROM:" address. I know I can control the "@domain.com" address by modifying the "mydomain" in Postfix main.cf file and I had to do that in order to stop e-mail from bouncing in the first place. The problems is now people are reply to "www-data@domain.com" and I don't want that.

This is a Plesk 9.5 server which as far as I know runs a stock standard Postfix installation. I would like advice on how to fix this problem in my PHP script.

share|improve this question

2 Answers 2

This is something you can do from your PHP script:

Have a look at Examaple #2 here:

$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);

This example also gives you control over the Reply-To headers. There's no need to touch anything in Postfix!

share|improve this answer

Use -f option(sender address):

<?php
mail('nobody@example.com', 'the subject', 'the message', null,
   '-fwebmaster@example.com');
?>
share|improve this answer
    
+1 Adding "-f" to the mail() function in PHP is easier then writing out all your headers by hand. –  Coops Feb 11 '11 at 13:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.