zend-mail icon indicating copy to clipboard operation
zend-mail copied to clipboard

Not overriding from mail header

Open vinodkumar30 opened this issue 9 years ago • 1 comments

When using smtp transport api for sending mail, 'from' header doesn't change by using ->setFrom() or ->setSender() and 'from' header always remains the same email address used for smtp user for authentication. In following example, from email address remains same as '[email protected]' instead of '[email protected]'.

Note: Sender name gets changed with 'Some Sender' (but not the email)

$transport = new SmtpTransport();
$options = new SmtpOptions();
$options->setHost('smtp.gmail.com')
                ->setConnectionClass('login')
                ->setName('smtp.gmail.com')
                ->setConnectionConfig(array(
                    'username' =>'[email protected]',
                    'password' => 'mypassword',
                    'ssl' => 'tls'
        ));
$transport->setOptions($options);
 
$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('[email protected]', 'Some Sender');
$mail->addTo('[email protected]', 'Some Recipient');
$mail->setSubject('TestSubject');
$mail->send($transport);

vinodkumar30 avatar Nov 21 '16 09:11 vinodkumar30

This repository has been closed and moved to laminas/laminas-mail; a new issue has been opened at https://github.com/laminas/laminas-mail/issues/46.

michalbundyra avatar Jan 15 '20 19:01 michalbundyra