简体   繁体   English

如何使用 php mail() 从 aws 服务器发送邮件?

[英]How to send mail from aws server using php mail()?

Using php mail() I am able to send email from cpanel but the same code is not working in aws server.使用 php mail() 我可以从 cpanel 发送电子邮件,但相同的代码在 aws 服务器中不起作用。 below is my code.下面是我的代码。

$to="mymail@gmail.com";
$subject="Hello";
$message="Welcome Onboard";
$headers  = "From:Test<test@gmail.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html\r\n";

$retval = mail($to,$subject,$message,$headers);
return $retval;

You should be able to send sendmail() in AWS but the service needs to be up and running in your instance.您应该能够在 AWS 中发送sendmail()但该服务需要在您的实例中启动并运行。 Check this link on how to get that started.检查此链接以了解如何开始。

Alternatively, you could use AWS SeS service, which works really well and is more robust.或者,您可以使用 AWS SeS 服务,该服务运行良好且更强大。 Check out this answer to see how that can be accomplished (pretty simple).查看此答案以了解如何实现(非常简单)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM