How can I set a proper FROM field for the PHP Mandrill library?
In Java, I can use:
from = "Some Description <[email protected]>";
If I try the same in PHP, I get an error:
Validation error: {"message":{"from_email":"The username portion of the email address is invalid (the portion before the @: Some Description
Only emails with FROMs like this get through:
$from = "[email protected]";
In case it matters, here's how I send an email:
$from = "Some Description <[email protected]>";
$message = array("subject" => $aSubject, "from_email" => $from, "html" => $aBody, "to" => $to);
$response = $mandrill->messages->send($message, $async = false, $ip_pool = null, $send_at = null);
If you read the documentation https://mandrillapp.com/api/docs/messages.html it has two parameters in request
from_email
and from_name
when we pass
$from = "Name <email>"
,
It is not accepted by mandrill hence it throws error , To pass a name you need to pass from_name with name value.