使用Amazon EC2实例的SMTP Gmail服务器发送电子邮件 [英] Sending email using smtp gmail server from Amazon EC2 instance

查看:403
本文介绍了使用Amazon EC2实例的SMTP Gmail服务器发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于企业emailId的gmail,并希望将其用于向我的客户发送消息。我正在使用smtp.gmail.com从asp.net mvc应用程序发送消息。这在我的本地主机上工作正常。但是,当我将代码部署到Amazon EC2时,功能中断了。我搜索发现EC2 IP已被Google涂黑。我该如何解决?我读到一种方法是使用Amazon SES,但是谁能说出它是如何工作的?它只是一种验证策略实施措施,是否支持从所述gmail帐户发送电子邮件?还有其他解决方法吗?

I have a gmail for business emailId and would like to use it for sending out messages to my clients. I am using smtp.gmail.com to send out messages from an asp.net mvc application. This works fine on my localhost. But when I deployed the code to Amazon EC2, the functionality broke. I searched and found that EC2 IPs are blackisted by google. How should I fix this? I read that one way is to use Amazon SES, but can anyone tell how does it work? Is it just a verification policy enforcement thing and does it support sending out email from the said gmail account? Is there any other workaround?

编辑1 :如建议的那样,我已联系Amazon提供生产访问权限。

Edit 1: As suggested I have contacted Amazon to provide production access. It is in process.

同时,我看到我能够从应用程序发送邮件。这些是我的设置-

Meanwhile, I am seeing that I am able to send mails from my application. These are my settings -

WebMail.SmtpServer = "smtp.gmail.com";
WebMail.SmtpPort = 587;
WebMail.EnableSsl = true;
WebMail.UserName = "me@example.com";
WebMail.From = "me@example.com";
WebMail.Password = "MyPassword";
WebMail.SmtpUseDefaultCredentials = false;

是否存在突然起作用的原因。

Is there a reason why suddenly it is working. Is this intermittent or can I move on to using this as such?

推荐答案

SES是解决此问题的方法,然后很好事实是,除非您要发送成千上万的电子邮件,否则只需花几分钱就可以了-它可以让您发送电子邮件,并使它来自(或似乎来自)您的gmail帐户。

SES is the solution for this problem, and then good thing is, unless you are sending 10's of thousands of emails it will only cost you pennies to do - it will allow you to send an email, and make it come from (or appear to come from) your gmail account.

第一步是向SES确认您拥有/控制要发送的电子邮件地址,这可以通过单击发送到该地址的电子邮件中的链接来完成,或者将一些TXT条目添加到您的DNS设置中。如果您控制域,则我更喜欢使用DNS方法,以便我可以验证整个域是否可以发送电子邮件,而不仅仅是一个帐户-然后您可以执行诸如从 sales@mydomain.com, billing @发送的操作mydomain.com'等,而无需分别验证每个电子邮件地址。

First step is to verify to SES that you own/control the email address you want to send from - that can be done by clicking on a link in an email they send to that address, or else adding some TXT entries to your DNS settings. If you control the domain, I prefer to use the DNS method so that I can verify the entire domain for sending emails, not just the one account - then you can do things like send from 'sales@mydomain.com', 'billing@mydomain.com' etc w/out having to verify each email address individually.

验证帐户后,使用SMTP选项从SES发送电子邮件与通过任何其他SMTP服务器进行发送-使用来自亚马逊的SMTP服务器名称,用户名和密码,您便可以使用。

Once you account is verified, sending email from SES using the SMTP option is exactly the same as sending it thru any other SMTP server - use the SMTP server name, username and password from amazon, and away you go.

非常容易,非常便宜,并且电子邮件发送非常方便

Very easy, very inexpensive and emails are sent very fast.

请注意,默认情况下有限制-我认为默认情况下为5 /秒,每月默认为10,000 /月-但如果您有合理的需要,可以增加该限制。

Be aware there are limits by default - I believe 5/second and 10,000/month by default - but that can be upped if you have a legitimate need.

此外,一旦您的帐户设置了SES,您就不仅限于从EC2实例发送电子邮件,您可以在任何地方使用它-例如我的Outlook电子邮件, Mac和我的iPhone都使用SES作为我的SMTP提供程序。

Also, once your account is setup with SES, you are not limited to sending your emails just from EC2 instance, you can use it anywhere - for example my outlook email, my mac and my iphone all use SES as my SMTP provider.

这篇关于使用Amazon EC2实例的SMTP Gmail服务器发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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