note 104594 deleted from function.mail by tularis

From: Date: Mon, 13 Jun 2016 10:30:07 +0000
Subject: note 104594 deleted from function.mail by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-205701@lists.php.net to get a copy of this message
Note Submitter: me at arronwoods dot com ---- I've had all sorts of problems with scripts that don't set the "-f user@example.org" parameter when using mail() if postfix is the sendmail agent. In postfix I had SMTP relay authentication based on the sender address, but it was always the PHP user as the sender until I adapted the code from: <?php mail('test@example.org', 'Subject', 'Body', 'From: user@example.org'); ?> to: <?php mail('test@example.org', 'Subject', 'Body', 'From: user@example.org', '-f user@example.org'); ?> I couldn't find a way to adjust PHP or Postfix to do this for me, so I had to edit the application. I was actually using Zend_Mail_Transport_Smtp, which made it that little bit trickier. I ended up with this: <?php class My_Mail_Transport_Sendmail extends Zend_Mail_Transport_Sendmail { public function _sendMail() { if ($this->parameters === null) { $this->parameters = '-f ' . $this->_mail->getFrom(); } return parent::_sendMail(); } } ?>

« previous php.notes (#205701) next »