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:

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

      <smtp from="">
        <network host="" port="587" enableSsl="true" userName="" password="pppaaassswwwooorrrddd" />
</smtp> </mailSettings> </>

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

Thank you and see you soon!


Top 1 Anti-spam email filter

Hello friends,

Let's imagine that you need an anti-spam filter for your e-shop email address, for example when users send you emails, comments, etc., and you want to be sure there will be no spam at all (or at least 99%)

There are a lot of different plugins and technics, but I guess they are not so powerful as you need, as well as me.

After a few days thinking about it I came to one idea - what if your email server would be able to send immediate response to sender to confirm he is not a spammer? Sounds great for me, so here are steps on how to do it:

- User or spammer send email to your email inbox

- Top 1 anti-spam filter gets every email, moves it into lets say "Waiting Approval" folder and sends an immediate email in response with unique URL for confirmation

- If that was an email from a real user he will get the email and navigate to the URL(spammer will not I guess)

- The URL will be a simple page with Google CAPTCHA (server-side validation of course) and confirmation button + the unique id

- Clicking the confirmation button will confirm humanity and move the original email back to inbox folder so you would see you have a humanity-confirmed new email

That's it. What do you think?

Thank you and see you later ;)