How do I use Gmail SMTP with port 587 on AWS EC2?

时光怂恿深爱的人放手 提交于 2019-12-03 14:42:36

I have fixed issue as of now for a development server. Please, not it's not the correct way to a production site.

For sending an email from AWS EC2 using Gmail SMTP service please follow below steps.

  1. Edit security group of your EC2 Instance.
  2. Edit inbound rules of the security group.
  3. Add 587 port in inbound rules. See below image.

you need to set your instance inbound rules for coming mail and outbound for send.

After that, you can send email using 587 SMTP port from AWS EC2.

Please read this article. https://support.google.com/accounts/answer/6010255?hl=en

https://myaccount.google.com/lesssecureapps

According to Googles documentation, you can use the G Suite SMTP relay service through port 25. You can read more information here:

https://support.google.com/a/answer/176600?hl=en

and here:

https://support.google.com/a/answer/2956491

Hope this helps!

To send email from C# hosted on Amazon EC2, make sure you have two things done.

  1. Use following setting in your Web.config
<mailSettings>
      <smtp deliveryMethod="Network" from="<from email goes here>">
        <network host="smtp.gmail.com" port="587" enableSsl="true" userName="email id goes here" password="<password goes here> />   
      </smtp>
    </mailSettings>
  1. Login the above gmail account onto the Amazon EC2. If you do not login, then gmail blocks the email being sent from code due to security reasons.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!