简体   繁体   English

使用 Amazon EC2 实例发送邮件

[英]Send Mail Using Amazon EC2 Instance

I am using Amazon EC2 Instance for one of my project, I have installed LAMP on linux server and now while I am trying to send email using simple function it is not sending email also is not giving any error for that.我正在为我的一个项目使用 Amazon EC2 实例,我已经在 linux 服务器上安装了 LAMP,现在当我尝试使用简单功能发送电子邮件时,它不发送电子邮件也没有给出任何错误。

Things I have done so far.到目前为止我所做的事情。

  • Created SES account.创建了 SES 帐户。
  • Used simple mail function.使用简单的邮件功能。
  • Enabled port 25 in security groups.在安全组中启用端口 25。

I solved this issue just by installing sendmail in my instance.我只是通过在我的实例中安装 sendmail 解决了这个问题。 Just run bellow command in your terminal只需在终端中运行波纹管命令

sudo apt-get install sendmail

That worked for me那对我有用

如果您使用的是亚马逊 ec2 ami/linux 发行版,请在 SSH 中使用“sudo yum install sendmail”

Although your problem relates to Sendmail have you tried following Amazons Documentation?尽管您的问题与 Sendmail 相关,但您是否尝试过遵循 Amazons 文档?

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp-app.html http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp-app.html

This uses postfix but it seems like a better alternative and there's help readily available for it.这使用了 postfix,但它似乎是一个更好的选择,并且可以随时获得帮助。

You also can use SMTP as Amazon SES supports this:您也可以使用 SMTP,因为 Amazon SES 支持此功能:

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp.html http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp.html

I know this doesn't directly answer your question.我知道这并不能直接回答您的问题。 You might just need to configure the mail settings in php.ini .您可能只需要在php.ini配置mail设置。

If you are using AWS SES you need to make sure you validate the account first:如果您使用 AWS SES,您需要确保首先验证账户:

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html http://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html

With the exception of addresses containing labels (see below), you must verify each email address that will be used as a "From" or "Return-Path" address for your messages.除了包含标签的地址(见下文),您必须验证将用作邮件“发件人”或“返回路径”地址的每个电子邮件地址。 The entire email address is case-sensitive.整个电子邮件地址区分大小写。 For example, if you verify sender@example.com, you cannot send emails from sender@EXAMPLE.com unless you verify sender@EXAMPLE.com also.例如,如果您验证 sender@example.com,则您不能从 sender@EXAMPLE.com 发送电子邮件,除非您也验证 sender@EXAMPLE.com。 (Domain verification, however, is case-insensitive. For more information, see Verifying Domains in Amazon SES.) (但是,域验证不区分大小写。有关更多信息,请参阅在 Amazon SES 中验证域。)

Until you are granted production access to Amazon SES, you must also verify the email address of every recipient except for the recipients provided by the Amazon SES mailbox simulator.在您获得对 Amazon SES 的生产访问权限之前,您还必须验证每个收件人的电子邮件地址,但 Amazon SES 邮箱模拟器提供的收件人除外。 For more information about the mailbox simulator, see Testing Amazon SES Email Sending.有关邮箱模拟器的更多信息,请参阅测试 Amazon SES 电子邮件发送。 For more information about production access, see Requesting Production Access to Amazon SES.有关生产访问的更多信息,请参阅请求对 Amazon SES 的生产访问。

Alternatively, instructions mentioned in the following link can be followed.或者,可以遵循以下链接中提到的说明。 In this method installing postfix, sendmail or any other mail server is not required.在这种方法中,不需要安装 postfix、sendmail 或任何其他邮件服务器。

It uses the PHPMailer class to send email through Amazon SES using the SMTP interface.它使用 PHPMailer 类通过 Amazon SES 使用 SMTP 接口发送电子邮件。

https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-php.html https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-php.html

It took me a whole day to reach this simpler solution.我花了一整天才找到这个更简单的解决方案。

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

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