gMail Relay on CentOS and ClearOS
  • Alt Method (submission), use if default method didn't work
  • Variables
    • PEM pass phrase
      Common Name
      Gmail User
      Gmail Password
      Test Receipient Address
  • Install
    • Install postfix (If using ClearOS, replace postfix with app-postfix)
      • yum -y install postfix
    • Install openssl perl script
      • yum -y install openssl-perl
  • Generate a new CA (All defaults except PEM pass phrase PemPassPhrase and Common Name CommonName)
    • /etc/pki/tls/misc/CA.pl -newca
  • Generate the CA, key and cert
    • Prepare
      • cd /etc/postfix
    • key
      • openssl genrsa -out gmail.key 1024
    • Request (All defaults except Common Name CommonName)
      • openssl req -new -key gmail.key -out gmail.csr
    • pem (All defaults except PEM pass phrase PemPassPhrase , all answers Yes)
      • openssl ca -out gmail.pem -infiles gmail.csr
  • /etc/postfix/main.cf
    • Backup
      • cp -vf /etc/postfix/main.cf /etc/postfix/main.cf.original
    • Modify
      • echo "
      • # Gmail relay
      • relayhost = [smtp.gmail.com]:587
      • # auth
      • smtp_sasl_auth_enable = yes
      • smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
      • # tls
      • smtp_use_tls = yes
      • smtp_sasl_security_options = noanonymous
      • smtp_sasl_tls_security_options = noanonymous
      • smtp_tls_note_starttls_offer = yes
      • tls_random_source = dev:/dev/urandom
      • smtp_tls_scert_verifydepth = 5
      • smtp_tls_key_file = /etc/postfix/gmail.key
      • smtp_tls_cert_file = /etc/postfix/gmail.pem
      • smtpd_tls_ask_ccert = yes
      • smtpd_tls_req_ccert = no
      • smtp_tls_enforce_peername = no
      • # End Gmail relay" >> /etc/postfix/main.cf
  • /etc/postfix/sasl_passwd
    • echo "gmail-smtp.l.google.com gmail_user@gmail.com:gmail_password" >> /etc/postfix/sasl_passwd
    • echo "smtp.gmail.com gmail_user@gmail.com:gmail_password" >> /etc/postfix/sasl_passwd
  • postmap
    • postmap /etc/postfix/sasl_passwd
  • Restart Service
    • service postfix restart
  • Test (4 Methods)
    • echo "Test Body 1" | mail -s "Test Subject 1" to_receipient@mail.com
    • echo -e "Subject: Test Subject 2\nTo: to_receipient@mail.com\nTest Body 2" | sendmail -F "From Name" to_receipient@mail.com
    • mail -s "Test Subject 3" to_receipient@mail.com -- -f from_user@example.com
    • echo "Test Body 4" | mail -s "Test Subject 4" to_receipient@mail.com -- -f from_user@example.com