I'm using the cakePHP email component for sending mails from my application. Now the return-path has something like [email protected]
How can I set or rewrite the Return-Path value in emails when using the cakePHP Component?
I know how to do it when sending mails via 'mail' in PHP but the cakePHP email component seems to missing such a feature... or am I missing something? :)
In CakePHP 2 (where the Email Component is largely replaced by the CakeEmail class), you can do this configuration inside /app/Config/email.php:
class EmailConfig {
public $email = array(
...
// The next line attempts to create a 'Return-path' header
'returnPath' => '[email protected]',
// But in some sendmail configurations (esp. on cPanel)
// you have to pass the -f parameter to sendmail, like this
'additionalParameters' => '[email protected]',
...
);
}
Or if you need to do it just for a single email, something like this should work...
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail('MyConfig');
$email->from(...)
->to(...)
->subject(...)
->returnPath('[email protected]')
// Haven't tested this next line, but may possibly work?
->config(array('additionalParameters' => '[email protected]'))
->send();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With