Zend_Mail and Mailtrap : bad sender address

293 Views Asked by At

I'm sending email to mailtrap in this way

$mail = new Zend_Mail();
$mail->setFrom("[email protected]", 'Temporary sender name');

I am already using mail trap for a lot of projects, so I know that I can send email using these email address and name as "from"

What doesn't works

The problem is that $mail->send() throws an Exception

5.1.7 Bad sender address syntax

Little debug

So I debugged Zend code. I am now sure it's sending from as

Temporary sender name <[email protected]>

I also tried avoiding litteral name, so using only

 $mail->setFrom("[email protected]");

The header is written using only

 <[email protected]>

But nothing changed

What I'm not understanding

I am not able to understand if this very old Zend project is NOT sending at all the message or if Mailtrap is refusing.

Questions

  • What is wrong with this sender address ?
  • Is this an error from Zend_Mail or from Mailtrap?
  • And obviously, how to fix ?
1

There are 1 best solutions below

0
Dmitry Leiko On BEST ANSWER

You can try this way:

Zend_Mail::setDefaultFrom('[email protected]', 'Temporary sender name');
$mail = new Zend_Mail();
$mail->setBodyText('...Your message here...');
$mail->send($transport);