我有Lumen在Google App Engine实例上运行,一切都很棒,除了发送邮件。无论我尝试什么,标准PHP mail()
都会返回false
,我无法在日志中找到错误。
/**
* Deliver an email
*
* @param string $to_email
* @param string $body
* @param string $subject
*
* @return bool
*/
static public function send($to_email, $body, $subject)
{
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: Punkr/1.0';
return mail($to_email, $subject, $body, $headers);
}
有什么建议?
您的发送邮件不起作用可能是由于不同的原因:
use google\appengine\api\mail\Message;
try {
$message = new Message();
$message->setSender('[email protected]');
$message->addTo('[email protected]');
$message->setSubject('Example email');
$message->setTextBody('Hello, world!');
$message->send();
echo 'Mail Sent';
} catch (InvalidArgumentException $e) {
echo 'There was an error';
}
希望这能回答你的问题!!!!!