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?
@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?
@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
Every time I need info on something technical, I sift through dozens of sites and pages full of wordy novices and impatient experts half-heartedly helping. This is the third time I’ve dealt with that crap before finding your blogs.
Thanks, DigitalOcean, for having such helpful and informative blogs. You’ve cured three headaches now, and you’ll be top of my list for searches in the future.
Fine and nice
Current limit is not 99 emails per day, that’s the maximum number of recipients per message.
Current limits are available on this help page.
I did all of the steps for authentification but I still the message gmail does not accept the password. On my iphone the Server says SMTP server not smtp.gmail.com . I hope someone knows how to fix this! thxs Debra
Hello Can I send email from my localhost server by modifying SMTP settings in php.ini file of Xamp having internet connection?
I think the number of messages per day is not 99 but 2000.
Here’s the limits table: https://support.google.com/a/answer/166852
Actually, it appears as though the sending limit is higher than 99. The 99 seems to only apply to the number of recipients in a SINGLE message:
https://support.google.com/a/answer/176600?hl=en
The way I interpret this, your app can send 2000 messages per day.
I tried with above steps ,but its not working .please help
I’ve tried to setup gmail as mailserver like described in the tutorial, After that i get warnings from google that someone located in russia is trying to access my google account… Is my server/droplet compromised?
Can i configure SendBlaster with Gmail account to BulkMailing.
how to set the google smtp mail configration ???
How do you use this to send information from contact form to a myname@mydomain.com that I have set up through google apps that I setup via this tutorial ?
If this is not possible what is the best way to set up something to make this happen? I tried setting up postfix as send-only through the tutorial on this site but I can’t figure out how to get it to work with two different domains on the same server. I’m so lost. I had it working at one time then I setup pear and couldn’t get it to work again so I destroyed and started over. Am I right to assume pear mail and postfix do the same thing and that’s what caused the conflict?
To make a long story short - what is the best way to set up my Ubuntu 14.04 server to send information from a form on my site, either site, to my admin@mydomain.com ?
Another option is Mailgun (http://www.mailgun.com/)
Your First 10,000 Emails Are Free Every Month
Nice info bruh!!
I tried setting this up but Google is blocking my email and then I get a “sign-in attempt prevented” in my inbox, I can post the debug output if needed
How does this work with second-factor security?
“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.”
Where can I get access to these or find them? Somebody got into my account and deleted all of my emails and then deleted them out of the trash folder. I would like to get them back but can’t find help on Google’s Help page or Forums. I had important things saved in there that I need
Didn’t work for me unfortunately. I created a Sendgrid free account very quickly, though, and used the SMTP settings from their docs to set up my SMTP server on a Digital Ocean Discourse app.
hello
For MediaWiki, at least, I followed the directions above AND logged into the relevant Google Account and switched “Allow less secure apps” to yes / on. Worked like a charm.
For Google Workspace users
“Limits per user The maximum number of messages a user can send in a 24-hour period is 10,000. However, this can vary, depending on the number of user licenses in your Google Workspace account. A registered Google Workspace user can’t relay messages to more than 10,000 unique recipients in a 24-hour period.”
The method mentioned in this tutorial is outdated and does not work, because Google no longers third-party apps to sign in with username + password. Refer https://www.cubebackup.com/blog/how-to-use-google-smtp-service-to-send-emails-for-free/ for the new methods.
I am using LAMP on digitalocean and I am using php mail() function to send mail. I want to know that where to do all these settings. In which file I can do all these settings. Please help me .
nginix time out i don’t have any mail in the server any idéés thank’s this what said to me nginx An error occurred.
Sorry, the page you are looking for is currently unavailable. Please try again later.
If you are the system administrator of this resource then you should check the error log for details.
Faithfully yours, nginx.
Google now doesn’t accept login from less secure apps. So you need to go to https://myaccount.google.com/security scroll to the bottom and turn ON “Allow less secure apps: ON”. Now when you add the SMTP details to “Send as” google will accept them. You need to do this for the email ID you are adding in your Send as section.
Any one have problems using this with Perfex CRM? Can’t get it to send an invoice through smtp.
Why smtp.gmail.com do not ping in my droplet? I can not send email. “Apt-get update” do not connecting to google service.
For OpenCart user by benjispeer:
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.
Accounts? There is some alternative DO smtp service to the google অনেক
It seems this no longer works, or at least I haven’t been able to get it to. Some comments elsewhere suggest that Gmail SMTP is now usable only by paid G-Suite subscribers. Could someone confirm this is actually so? If that’s the case, are there any good free alternatives?
Username + password does not work anymore, no matter for Gmail or Google Workspace account. However, personal Gmail accounts can still use Google SMTP service with “App password”. And Google Workspace users can use “less secure app” and “SMTP relay service” to send email messages, see https://www.cubebackup.com/blog/how-to-use-google-smtp-service-to-send-emails-for-free/ for detailed information.
NanitesMedia.com If anybody is looking for SMTP Server then I can provide you the best SMTP solution all you have to do just register with us i will give you the best SMTP server …
http://app.nanitesmedia.in/customer/index.php/guest/register For more information visit our website:—>> https://www.nanitesmedia.com/ or chat me on Skype:-- nanitesmedia@outlook.com
:–>>Ones the Signup and payment are done you just have to give us domain for SMTP Server Setup we will give the nameserver.
:–>>Our all the SMTP Server sending speed is 250 from 1 IP each hour. for example:-- 10 IP SMTP Server 25010=250024=60,000 in 24 hour and 18,00,000 email in 1 Month… In case if your IP gets blacklisted then we will change that IP. :–>>our all the IP has Neutral REPUTATION. :->>we are the only one who gives you guaranteed that in any manner your server will not get suspended.
1:-- Nanites Mail ( SMTP with 25 IP )
Authentications – DKIM, SPF, DMARC, rDNS
Activate in 48 hours
2:-- Nanites Mail ( SMTP with 50 IP )
Authentications – DKIM, SPF, DMARC, rDNS
Activate in 48 hours
hallo