note 104594 added to function.mail

From: Date: Fri, 24 Jun 2011 14:42:53 +0000
Subject: note 104594 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-180912@lists.php.net to get a copy of this message
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(); } } ---- Server IP: 69.147.83.197 Probable Submitter: 81.134.144.135 ---- Manual Page -- http://www.php.net/manual/en/function.mail.php Edit -- https://master.php.net/note/edit/104594 Del: integrated -- https://master.php.net/note/delete/104594/integrated Del: useless -- https://master.php.net/note/delete/104594/useless Del: bad code -- https://master.php.net/note/delete/104594/bad+code Del: spam -- https://master.php.net/note/delete/104594/spam Del: non-english -- https://master.php.net/note/delete/104594/non-english Del: in docs -- https://master.php.net/note/delete/104594/in+docs Del: other reasons-- https://master.php.net/note/delete/104594 Reject -- https://master.php.net/note/reject/104594 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180912) next »