Sending email using smtp gmail server from Amazon EC2 instance - asp.net-mvc

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?
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 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.
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.
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.
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.
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.

I was actually able to send an email using an EC2 instance. Try editing your SMTP Server to ssl://smtp.gmail.com

Related

Bamboo Mailer & SES Failing to send an email to one specific user

I am working on a production server that sends roughly 1000 emails a day with almost no issues. There is a single email that always fails and I have been unable to send an email to this user through our system. The site is built with Elixir and uses the Bamboo Mailer, specifically the smtp_adapter but I believe this may be an issue with SES rather than our code or the Elixir libraries we are using.
The particular user always throws this error:
{{:nocatch, {:permanent_failure, "501 Invalid RCPT TO address provided\r\n"}},
From what I can tell the email address is valid and the customer has verified it as such and stated that emails have been sent and received to the user outside of our system.
I'm looking for some context on how SES determines what a valid RCPT TO address is and more generally how SES works to send emails. I haven't been able to find much on this issue from the SES docs.

Sending email with AWS SES without custom domain

I would like to send email from a Rails 5.1 app with AWS SES through smtp, but without using a custom domain (it's ok if users receive emails with an address from aws). But when searching through AWS documentation or google, I can only find instructions to use custom domains.
Is it possible? And if yes, what email address (mail FROM) should be used to replace the placeholder in config/initializers/devise.rb:
config.mailer_sender = 'please-change-me-at-config-initializers-devise#example.com'
?
You don't need to have a custom domain, but you do need to have at least an email address you can verify following the procedure outlined in https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html
AWS doesn't have "default" email addresses to use for sending mails. Note also, that SES require you to handle bounces and such.

Sending email to the "outside world" from localhost using hMailServer and Gmail SMTP on Windows 7

I am not sure if this is technically possible but I am running a AMPPS box on Windows 7 as my localhost and I have configured it with Gmail SMTP (ssl://smtp.gmail.com) to send out email from my PHP scripts like joomla, wordpress, socialengine, etc.
Now I installed and setup hMailServer and I am able to send and receive emails locally but was wondering if there was a simple way that I could configure my localhost and email server to send out email to outside world (e.g. #hotmail.com or #yahoo.com receipients) using Gmail SMTP?
Currently with my setup, I am only able to receive installation confirmation emails from AMPPS but nothing else like "Forget Password" or "User Registration Forms" work.
Any ideas without getting too deep into code modification?
The simple answer is no, or rather it is far from easy, especially from a home based server.
And the reason is that your IP address amd mail server domain will not be considered as a ligitimate mail server by most of the legitimate mailservers you will be trying to send mail to, and they will just reject it as yet another spam server.
Have a look at these:
https://serverfault.com/questions/72559/setting-up-a-mail-server-best-practices-to-be-recognized-as-legitimate
How to conduct legitimate email campaigns

How to keep IP trust from email companies when developing in local/test

I am using sendgrid on my Rails app that I am beginning to build.
I am in test mode, mostly doing local stuff but I send many emails to check my process or email layout.
The email I use to receive the emails is on Gmail. I fear Gmail will see there are many emails everyday and never an answer and maybe that the CSS changes a lot, and maybe other factors gmail take into account to assess the trust level of an IP sending emails...
Do I risk Gmail to decrease the trust level of my sendgrid IP? (I don't have much choice during test mode I think)?
What could I do to avoid the IP trust getting hit?
You could use mailtrap to avoid polluting true email addresses. You may check emails sent from their web interface or manually forward them to your inbox.
You could use mailcatcher to catch and view your emails sent from localhost.
MailCatcher runs a super simple SMTP server which catches any message
sent to it to display in a web interface. Run mailcatcher, set your
favourite app to deliver to smtp://127.0.0.1:1025 instead of your
default SMTP server, then check out http://127.0.0.1:1080 to see the
mail that's arrived so far.
In order for you to use it:
gem install mailcatcher
mailcatcher
Go to http://localhost:1080/

sending e-mail from Rails Web app without using smtp

I just try to send an e-mail to signed up user from my rails web app. Do I need to use any smtp server or can I just send a mail from my app.? Do you have any suggestion idea about this? Thanks for returns :)
Yes, you need an SMTP server for sending mail.
There are two options, first is to use a mail server provided by someone else, e.g. the SMTP of the company that provides your server or their ISP.
The other option is to install a MTA (Mail Transfer Agent) on your server, one popular options is postfix. See here for instructions for Ubunutu.

Resources