phpsmtpzend-mailmailtrap

Zend_Mail and Mailtrap : bad sender address


I'm sending email to mailtrap in this way

$mail = new Zend_Mail();
$mail->setFrom("senderaddress@yahoo.it", '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 <senderaddress@yahoo.it>

I also tried avoiding litteral name, so using only

 $mail->setFrom("senderaddress@yahoo.it");

The header is written using only

 <senderaddress@yahoo.it>

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


Solution

  • You can try this way:

    Zend_Mail::setDefaultFrom('senderaddress@yahoo.it', 'Temporary sender name');
    $mail = new Zend_Mail();
    $mail->setBodyText('...Your message here...');
    $mail->send($transport);