Code Optimization

Interesting things about software development and code optimization

Gmail G Suite as SMTP server for your website

Hello friends!


Its time to share so non obviouse case as using G Suite Gmail account and SMTP server to send emails from your website.

(it seems different than using private Gmail account)


Check restrictions and rules google uses for such sending emails scheme


First step and the most time consuming is to Enable less secure applications!

Go to the G Suite Admin > Security > Less secure apps 

and enable "Allow users to manage their access to less secure apps"

Pay attention - it really may take up to 24 hours before you see this "Less secure" option available 


While you are waiting you can do some other steps.

Go to the gmail account you are going to use and click on the top-right settings icon:



and select "Settings". Go to the POP/IMAP tab and enable POP and IMAP Access options.


Next step - add an SMTP Relay rule to allow your email accounts be accessible from outside:

G Suite Admin > Apps > G Suite > Gmail > Advanced Settings > SMTP relay service

Hover over this section and click the Add button. 

Add the following rule:



Wait some time until this option is available under the G Suite Gmail (email) account and turn it on:
https://myaccount.google.com/u/2/lesssecureapps?pageId=none


Final step - use the following mail configuration in your website:

  <system.net>
    <mailSettings>
      <smtp from="no-reply@mygsuitedomain.com">
        <network host="smtp-relay.gmail.com" port="587" enableSsl="true" userName="no-reply@mygsuitedomain.com" password="pppaaassswwwooorrrddd" />
</smtp> </mailSettings> </system.net>



That's it! Now you can send emails :)


Thank you and see you soon!


1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y