2017-01-30 48 views
1

如何爲PHP Mandrill庫設置適當的FROM字段?Mandrill PHP庫 - FROM字段

在Java中,我可以使用:

from = "Some Description <[email protected]>"; 

如果我試圖在PHP一樣,我得到一個錯誤:

Validation error: {"message":{"from_email":"The username portion of the email address is invalid (the portion before the @: Some Description

與櫨這樣才電子郵件打通:

$from = "[email protected]"; 

萬一它很重要,這裏是我如何發送電子郵件:

$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); 
+0

上一個工作正常與PHP顯示我們的代碼,它會給你錯誤。 –

+0

你的意思是第一個? – Buffalo

+0

爲mandrill php庫看看如何設置發件人的名字在這裏https://mandrillapp.com/api/docs/messages.php.html有一個參數叫from_name – webDev

回答

-1

如果你閱讀文檔https://mandrillapp.com/api/docs/messages.html它在要求兩個參數 from_emailfrom_name當我們通過

$from = "Name <email>"

它不是由山魈所接受,因此它拋出的錯誤,要通過一個名字你需要傳遞具有名稱值的from_name。

+0

這將是非常合適的,如果你提到downvote的原因.. –

+0

謝謝,它的工作完美無瑕。另外,我沒有投票。我被Java API誤導了,不需要將兩個字符串分開。 – Buffalo