OraOpenSource / OXAR

Oracle XE & APEX build script along with images for popular cloud platforms
http://www.oraopensource.com/oxar/
MIT License
107 stars 42 forks source link

Add Gmail SMTP service support #111

Open martindsouza opened 8 years ago

martindsouza commented 8 years ago

A lot of people have said they couldn't get the email server done easily. Maxime Tremblay suggested the following to link to Gmail (no wallet required): https://charlesauer.net/tutorials/centos/postfix-as-gmail-relay-centos.php

This should be an optional component and need to include some additional parameters in the config file (for gmail address, etc)

maxime-tremblay commented 8 years ago

Note : This could also work using any smtp server. I only tested for Gmail and it's working great so far.

For Gmail

In order to send emails with Gmail using the relay smtp server, you will need to change one of the Gmail account setting. Go into "My Account", then in the "Connected apps & sites" section, turn on the "Allow less secure apps" option.

Apex Internal Config

You can use the default values which are SMTP Host Address: localhost SMTP Host Port : 25

Security

As mentionned in the procedure, make sure to remove the /etc/postfix/sasl_passwd file when you are done setting the relay up as it contains the smtp's account password in clear. The relay is using the /etc/postfix/sasl_passwd.db file which is hashed.

GasparYYC commented 8 years ago

Obviously create the Gmail account.. That is manual and can't be scripted. But the server configuration boils down to the following commands that can be easily scripted:

As root

yum install postfix mailx cyrus-sasl-plain cd /etc/postfix/ echo "smtp.gmail.comemailaccount@gmail.com:password" > /etc/postfix/sasl_passwd postmap hash:/etc/postfix/sasl_passwd

Erase the one with clear text password rm sasl_passwd

Append the following configuration to Postfix in /etc/postfix/main.cf echo 'smtp_sasl_auth_enable = yes > smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd > smtp_sasl_security_options = noanonymous > # Secure channel TLS with exact nexthop name match. > smtp_tls_security_level = secure > smtp_tls_mandatory_protocols = TLSv1 > smtp_tls_mandatory_ciphers = high > smtp_tls_secure_cert_match = nexthop > smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt > relayhost = smtp.gmail.com:587' >> /etc/postfix/main.cf

Restart Postfix

service postfix restart

Send Test email...

[root@host postfix]# mail otheremailaccount@provider.com Subject: Mail using gmail! Whatever ^d EOT [root@host postfix]#

Check your otheremailaccount@provider.com email (could be your personal email) You should have received an email from your newly created gmail account

NOTE for Gmail (Pre-Requisite)

Ensure you setup the Gmail account setting to Allow less secure apps.. Go into "My Account" (top right round picture or generic icon), then in the "Connected apps & sites" section, turn ON the "Allow less secure apps" option.

NOTE For APEX

Ensure you have activated the ACL prior to trying to send emails or mail will be queued and not sent out

Adding to the Apex Internal Config from Maxime (see Comment above)

I recommend the that you leave following fields empty (careful cause Chrome will autofill if you have it to save credentials): SMTP Authentication Username SMTP Authentication Password Or you will get this error: ORA-29279: SMTP permanent error: 503 5.5.1 Error: authentication not enabled Frankly speaking I don't know what values goes there but no matter what I have gives error but blank works fine!

Thanks to @maxime-tremblay for his help.