在以下函數中,$ aFrom變量將「from」字段設置爲收件人可以回覆的電子郵件地址。但是,如果我想添加「來自」名稱,該怎麼辦?例如,我的電子郵件地址是[email protected],但是當該人收到電子郵件時,我希望他們看到該電子郵件來自「John Doe」。儘管如此,他們仍然可以回覆[email protected]。在php郵件函數中添加「from」名稱
public static function SendMail_HTML($aFrom, $aTo, $aSubject, $aMessage) {
$theHeaders =
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=UTF-8' . "\r\n" .
'From: ' . $aFrom . '' . "\r\n" .
'Reply-To: ' . $aFrom . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($aTo, $aSubject, $aMessage, $theHeaders);
}
你會希望它是'來源:李四<[email protected]> '。 – ceejayoz
可能的重複[更改發件人名稱php郵件,而不是[email protected]](http://stackoverflow.com/questions/8365754/change-the-sender-name-php-mail-instead-of-sitenamehostname- com) –