Google Cloud Platform Quick Setup for Sending Mails.


a bit complicated procedure, since you need to have a 3rd party's account, SendGrid.

Send Grid is free for 100 mails/day forever. as of 2019/10/28.

  1. SendGrid Account for API Key
    1. Sign in or Create an account: SendGrid
    2. Settings -> API Keys
  2. Postfix installation on your instance(Google-Cloud).
    1. $ ssh google cloud.
    2. $ sudo su - (from google cloud help)
    3. # umask 077 (from google cloud help)
    4. # apt-get install postfix
      • Select "Local only".
      • Accept "instance-1.us-central1-a.c.voltaic-psyche-2*.internal".
    5. # emacs /etc/postfix/main.cf
      • comment out
        #default_transport = error
        #relay_transport = error
        
      • Add below
        relayhost = [smtp.sendgrid.net]:2525
        smtp_tls_security_level = encrypt
        smtp_sasl_auth_enable = yes
        smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
        header_size_limit = 4096000
        smtp_sasl_security_options = noanonymous
        
    6. # emacs /etc/postfix/sasl_passwd
      [smtp.sendgrid.net]:2525 apikey:YOUR_API_KEY
      
    7. postmap /etc/postfix/sasl_passwd # to create sasl_passwd.db
    8. /etc/init.d/postfix restart
    9. Test
      • # apt-get install mailx
      • # echo 'test' | mail -s subject test@testc.com
      • You will get the email immediately! Done!
      • # tail -n 5 /var/log/syslog # for checking!

Since 20191029