如何使用 php mail() 从 aws 服务器发送邮件? [英] How to send mail from aws server using php mail()?

查看:38
本文介绍了如何使用 php mail() 从 aws 服务器发送邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 php mail() 我可以从 cpanel 发送电子邮件,但相同的代码在 aws 服务器中不起作用.下面是我的代码.

Using php mail() I am able to send email from cpanel but the same code is not working in aws server. 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;

推荐答案

您应该能够在 AWS 中发送 sendmail() 但该服务需要在您的实例中启动并运行.查看此链接,了解如何开始.

You should be able to send sendmail() in AWS but the service needs to be up and running in your instance. Check this link on how to get that started.

或者,您可以使用 AWS SeS 服务,该服务运行良好且更强大.查看这个答案以了解如何实现完成(很简单).

Alternatively, you could use AWS SeS service, which works really well and is more robust. Check out this answer to see how that can be accomplished (pretty simple).

这篇关于如何使用 php mail() 从 aws 服务器发送邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆