【问题标题】:How to send mail from aws server using php mail()?如何使用 php mail() 从 aws 服务器发送邮件?
【发布时间】:2020-05-15 17:26:00
【问题描述】:

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

$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;

【问题讨论】:

  • code is not working in aws server 什么不工作,你得到错误或什么?
  • 我收到的邮件是成功发送的电子邮件,但收件箱中没有收到
  • 您的 PHP 实例是用什么设置来发送邮件的?如果是sendmail 之类的东西,它是否真的安装在您的服务器上? AWS 是否允许从其服务器发送邮件?我确实找到了在 AWS 上发送电子邮件的参考:docs.aws.amazon.com/ses/latest/DeveloperGuide/…

标签: php amazon-web-services amazon-ec2


【解决方案1】:

您应该能够在 AWS 中发送 sendmail(),但该服务需要在您的实例中启动并运行。 检查this link 了解如何开始。

或者,您可以使用 AWS SeS 服务,它运行良好且更强大。 查看this answer 了解如何实现(非常简单)。

【讨论】:

    猜你喜欢
    • 2014-05-28
    • 2011-09-28
    • 2019-06-20
    • 2013-06-12
    • 2018-02-24
    • 1970-01-01
    • 2021-10-01
    相关资源
    最近更新 更多