The author selected the COVID-19 Relief Fund to receive a donation as part of the Write for DOnations program.
A little-known feature of Gmail and Google Apps email is Google’s portable SMTP server. Instead of having to manage your own outgoing mail server on your DigitalOcean Droplet or Kubernetes Cluster, you can configure Google’s SMTP server settings with whatever script or program you wish to send email. All you need is either (i) a free Gmail account, or (ii) a paid G Suite account.
Note: As of June 22, 2022, DigitalOcean is blocking SMTP for all new accounts. As a part of this new policy, we have partnered with SendGrid so our customers can still send emails with ease. You can learn more about this partnership and get started using SendGrid by checking out our DigitalOcean’s SendGrid Marketplace App.
You have the option of having Google store and index the emails you send via its SMTP server, so all your sent emails will be searchable and backed-up on Google’s servers. If you elect to use your Gmail or G Suite account for your incoming email as well, you’ll have all your email in one convenient place. Also, since Google’s SMTP server does not use port 25
, you`ll reduce the probability that an ISP might block your email or flag it as spam.
Google’s SMTP server requires authentication, so here’s how to set it up in your mail client or application:
Note: Before you begin, consider investigating your mail client or application’s security rating, according to Google. If you are using a program that Google does not consider secure, your usage will be blocked unless you enable less-secure applications (a security setting that Google does not recommend) or generate an application-specific App Password. For more security information, see this link to determine the best approach for your mail client or application.
example@gmail.com
or example@your_domain
)Your Gmail or G Suite email password
465
In order for Google to automatically copy your sent emails to the sent folder, you must also verify that IMAP access is enabled for your account.
To do so, go to the Gmail settings and click on the Forwarding and POP/IMAP tab. Scroll down to the IMAP Access section and make sure that IMAP access is enabled for your account.
Note: Google will automatically rewrite the From line of any email you send via its SMTP server to the default email address associated with the account if the one used is not on the Send mail as addresses list in Gmail or G Suite settings. You can verify the list by going to the Accounts and Import tab on the settings screen.
You need to be aware of this nuance because it affects the presentation of your email, from the point of view of the recipient, and it may also affect the Reply To setting of some programs.
Google limits the amount of mail a user can send through its portable SMTP server. This limit restricts the number of messages sent per day to 99 emails; the restriction is automatically removed 24 hours after you hit the limit.
You now have the option of using Google’s SMTP Server. If this lightweight option is not sufficient, you can consider installing and configuring postfix as a send-only SMTP server.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Could indicate managers emails to use with Droplets. I know: AfterLogic webmail Roundcube. Does anyone know more?
hello
@Rodrigo: I’m not sure I understand what you mean. Are you talking about webmail clients?
Do you know if the 99 mails limit is also applicable to google apps accounts? There is some alternative DO smtp service to the google one?
@igonzalezvaliente: Take a look at this: http://support.google.com/a/bin/answer.py?hl=en&answer=166852 I personally use Mandrill for sending email, but there are other alternatives such as SendGrid, Postmark, etc.
Contact me here (sgtsusanhelm2@hotmail.com) i like your profile and i want to discuss something private with you to see if you can render me some help about it.From sgtsusanhelm.
Thanks for the tip @Pablo Carranza: I also use SMTP2GO.com when I’m travelling, you can send more than 99 emails per day if required.
i found your article searching for ways to fix a gmail 535 error (i have a hotmail email accc) and was looking at alternative fixes (because msft help is useless)…I was hoping your workaround (change default email) would help, but aas not. Outside of using services like smpt2go, any ideas on how to get around the gmail login failure? thanks
@Kamal: You said that you use Mandrill for sending emails, and I am thinking of doing that, but is there a way of setting roundcube webmail for doing so, or I can use Mandrill just for desktop program configuration? Here is a picture of what I am doing: I have a droplet with zpanel installed, therefore it has roundcube, and it is receiving and sending emails, but I wasnt able to create/set a DKIM or Domain Keys, in order to sign my emails, I could do the SPF correctly, but some emails still go to the spam box when I send… Thats why I want to use Mandrill. Can you help me?
Kamal Nasser
Thanks for most useful post. works perfectly for me. working about it too long to find any normal SMTP server and its for free really great. and traffic i use is much less then it gives for free. THANKS!
felipe.campos
I use Kerio Connect as mailserver and it has a function of SMTP delivery where you can use another server for SMTP it also works in webmail mode because kerio connect is also a web server, its very simple and easy to use and also has all functions that most users need.
@KamalNasser - Do you use Mandrill for ALL outgoing email or just certain emails? Using it for all your outgoing email is interesting…g
@James: I use it for apps/websites that send mail. I use Google Apps for incoming/regular email (e.g. sent by me instead of the webserver). So it depends on who’s sending the email really.
@Kamal Nasser: Thanks a lot!! I have just send my first email using Mandrill.
@Kamal Nasser Hi there! How do you configure Redmine with Mandrill ? I try but must be a noob but it doesn’t work correctly in my redmine configuration. Please could you show me example of your configuration.yml ? Mine is like that : default:
Outgoing emails configuration (see examples above)
email_delivery: delivery_method: :smtp smtp_settings: address: smtp.mandrillapp.com port: 587 domain: example.net authentication: :xx@xxxx.com user_name: “xx@xxxx.com” password: “db9c3e3a-xx44-4cca-8e11-ae9x0aad2e62” Is it correct ? thx very much for your support cheers
@baudoux: Check out <a href=“http://help.mandrill.com/entries/23744737-Where-do-I-find-my-SMTP-credentials-”>http://help.mandrill.com/entries/23744737-Where-do-I-find-my-SMTP-credentials-</a>.
I’m on OpenCart install and I’m getting this error: Notice: Error: EHLO not accepted from server! in /var/www/system/library/mail.php on line 200. I think it’s some block port on my DO droplet. But I’m totally lost. I’ve spent so many days searching for a solution on OpenCart community without sucess
@jntslvdrt: Can you run <pre>telnet smtp.gmail.com 25</pre> from your droplet or does it time out? Also check if your droplet’s IP is blacklisted: <a href=“http://mxtoolbox.com/blacklists.aspx”>http://mxtoolbox.com/blacklists.aspx</a>.
If the IP address is showing listed in RFC clueless. Does it matter? One of my DO IP address showing in RFC clueless.
Reference: https://tools.pepipost.com/email-blacklist-checker/
Thanks for the reference. It really helped me to get resolve my issue.
My pleasure. Happy to help! P.S. The link is now redirecting to https://grademyemail.co/email-blocklist-checker
tnx
from sepidarchat.ir
All,
I’m having trouble configuring Google SMTP on my droplets. Can’t send email via webserver. Could someone please give me a hand? Thanks very much!
I am still not quite clear how this works. Where do we put all those settings?
@narin: In your app’s SMTP config.
I’m little confused would you please help me? I want to send email from php file using mail(); I can do that right now. However, all mails go to spam folder. So, I got google apps email with my domain name at the end. I also add google MX in DNS section. Now, what should I do next?
@djffalways: What stack/framework is your app built on? How did you try to configure SMTP?
I’m having trouble sending mails from Gmail on DigitalOcean droplets. I’m using a compiled MATLAB script - MATLAB relies on JAVA to send mails. I tried both SSL and TLS authentication configurations. Both work fine fine on my PC (both on Windows and linux), and they also work fine when running the same script on Amazon EC2. but on DigitalOcean I’m getting:
Java exception occurred: javax.mail.AuthenticationFailedException at javax.mail.Service.connect(Service.java:306) at javax.mail.Service.connect(Service.java:156) at javax.mail.Service.connect(Service.java:105) at javax.mail.Transport.send0(Transport.java:168) at javax.mail.Transport.send(Transport.java:98)
For the exact same script that runs fine on EC2. Any clue? Perhaps some linux configuration issue? I’m out of ideas…
OK, after finding this: http://stackoverflow.com/questions/17227532/gmail-530-5-5-1-authentication-required-learn-more-at
I discovered the Google was simply blocking the login attempts from the DigitalOcean IP. Logged in to Gmail and verified that it was a valid attempt, but it still doesn’t work :( Definitely a Gmail issue though.
You guys at DO might want to somehow register your IP ranges with Google to prevent such login blocks in the future (don’t know if such a thing is possible…)
Finally solved by using this link: https://www.google.com/accounts/DisplayUnlockCaptcha
And then running the script. Mysterious are the Google authentication mechanisms…
I’m also confused, is there a recommend app to use for this process? I just want to be able to send and receive emails from a “support@mydomain.com”. What is the quickest way to do this?
@jntslvdrt
If anyone is trying to setup Gmail SMTP for opencart, users will get this error when trying to create an account and other actions where emails are automatically sent:
“Notice: Error: EHLO not accepted from server! in /var/www/system/library/mail.php on line 200”
The solution to the problem is to add ssl:// before smtp.gmail.com in the hostname field for opencart mail settings. Since there is no built in option to specify ssl you have to just add that little bit before. After that, all should work perfectly.
Edit: After adding ssl:// for opencart users. You must also visit this link:
https://accounts.google.com/b/0/DisplayUnlockCaptcha
Make sure you are signed into the Google account you’re using for opencart SMTP.
Once you authenticate you must go to your opencart store and register a new account so that your store is authenticated with your google account. (This must be done within 10 minutes of clicking the above link.) You should get a successful account creation message and a new email in the email you used for the new account.
I cannot connect to smtp nor imap.gmail.com:
This causes a timeout:
user@machine:~$ telnet smtp.gmail.com 465 Trying 173.194.71.108…
user@machine:~$ telnet imap.gmail.com 993 Trying 173.194.71.109…
We are using ams2. Someone the same thing happens?
I’m having the same problem… Did you fxed?
You should run $ telnet smtp.gmail.com 587
Also if it takes “forever” before finally appearing to connect, you might have a broken Ipv6 on your droplet: http://serverfault.com/questions/512744/timeout-error-in-all-my-apps-for-every-call-to-smtp-servers for work around
@asanchez: Can you ping them? I just spun up a quick test instance in AMS2 and I’m able to telnet to smtp.gmail.com. Do you have outgoing ports blocked with iptables?
I have the same problem, I can ping smtp.google.com but when I try to send an email or connect using telnet gives me a timeout…
@nicolasbouhid: If you confirm that you have the outgoing ports open on your end, please open a support ticket. In certain instances those ports might be filtered to prevent abuse, but the support team should be able to clear that up for you:
https://cloud.digitalocean.com/support
Unfortunately for my box same issue (timeouts, cannot telnet to the IPv6 port) support just said “we have those ports disabled by default” (with IPv6) so I had to use some of the workarounds from here: http://serverfault.com/questions/512744/timeout-error-in-all-my-apps-for-every-call-to-smtp-servers (or switch to IPv4 only droplet). Cheers!
Hi, I am running a Joomla website and I am using the smtp setting as described in the post. When I try to send an email from a form of the website it says that the mail account doesn’t exists.
I have uploaded the same website (via backup), with the same smtp configuration, to a comercial shared server, and it works ok; I can send mails from the forms with no problem.
I have installed joomla on a droplet with Lamp on Ubuntu 12.04, and to make it work I have had to install some php5 libraries (for example php5-gd to upload images to a gallery…)
I have also read many post on forums about open ssh and other things that are needed, but I think everything it’s ok on my droplet.
My question is, do I need to install any additional library or php package to be able to use google’s smtp server??
Thank you in advance of your help
Luis
@info: You shouldn’t need to install additional php extensions. Can you connect to Google’s SMTP servers?
Hi Kamal,
With the command ‘nc -vz smtp.gmail.com 25’ I get the message : ‘nc: connect to smtp.gmail.com port 25 (tcp) failed: Connection timed out’ But with ‘ping smtp.gmail.com’ it seems to works fine: ‘— gmail-smtp-msa.l.google.com ping statistics — 202 packets transmitted, 202 received, 0% packet loss’
Should I open a ticket as suggested by Andrew SB to @nicolasbouhid on June 2? It seems to be a similar problem…
@info: Yes, please open up a support ticket.
Thanks
Thanks, was looking for something like this today.
See here for an example of using it via Python: http://www.mkyong.com/python/how-do-send-email-in-python-via-smtplib/
Note different port number (587) in the above example which worked for me; the port number you listed (465) did not work with the Python script in the example I linked.
Hi friend View this post, it may help you
You need to visit and download the free Promailer Marketing Manager provided by http://jsmtp.com and add these details into the smtpserver detail section you can add as many gmail, yahoo, hotmail, accounts and can also switch to get good delivery. http://jsmtp.com/how-to-send-unlimited-emails-using-gmail-smtp-bulk-mailer-software-and-mass-email.htm.
Regards skp : RanvirSharma
This comment has been deleted