How to pass extra parameter to mail function from magento
-
03-10-2020 - |
Question
I want to send extra parameter to mail
function in magento. I didn't find any raw mail
function in magento, can any one help me where I will get that function.
mail($to, $subject, $message, $headers, 'Iwantopassthis@test.com'); // I want to pass 5th parameter
Solution
If you magento is using sendmail to send an email, you can find the mail()
function in Zend_Mail_Transport_Sendmail
. Check the method public function _sendMail()
.
You can find this file in lib/Zend/Mail/Transport/Sendmail.php
of your magento 1 root and vendor/magento/zendframework1/library/Zend/Mail/Transport/Sendmail.php
in your magento2 root. Also it is not recommended to edit this file directly. If you want to modify this, copy this file to app/code/local/Zend/Mail/Transport/Sendmail.php
(there won't such directories by default but you can create) and then modify the method _sendMail()
;
OTHER TIPS
The additional_parameters parameter can be used to pass an additional parameter.
<?php
mail('nobody@example.com', 'the subject', 'the message', null,
'-fwebmaster@example.com');
?>
For more detail additional-parameters