How to use google apps smtp to email warnings

Carlos Gomes

Active Member
Jan 23, 2017
15
4
43
41
Chur, Switzerland
Hello everyone

I've tried many of the suggestions here on the forums and other methods using postfix to relay the warning mails to be sent using a google apps account, but with no success. Besides the suggestions on the forums, I tried this method - http://mhawthorne.net/posts/postfix-configuring-gmail-as-relay.html

that was where the logs changed, suggesting a help link about credentials:

Code:
Nov 21 20:56:13 pve111 postfix/smtp[32512]: 220A6775E: SASL authentication failed; server smtp.gmail.com[64.233.186.108] said: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbs6?534-5.7.14 loz7W7nzPJXCyHs6XPgNuDPu00XAlcFMtKU8XULcoE73wsxfGPjGaUFLdvUKJShG3ahKNK?534-5.7.14 OcAlJburGAtqSCBuke723LS3V0r6ZpPo6uWnEwn9t5HurL3DBoQzlU9zxQtQDcsZtJFxlc?534-5.7.14 -KfcV3XIQp9y0N7q7xR6iLULnMo7W9uHFMpdsX6Qfz9ETGYZddAy51PRqSUFmciQcOZz5i?534-5.7.14 DlL9iyq7aSMQDh47vLFzDdZBE7W5Q> Please log in via your web browser and?534-5.7.14 then try again.?534-5.7.14  Learn more at?534 5.7.14  https://support.google.com/mail/answer/78754 s19sm9632755qki.3 - gsmtp

Is there any other path to use foreign gmail / gapps on proxmox?
 
I managed to use the service, but I had to update the option inside google apps admin to allow the desired account to allow unsecured apps, and then all worked. Ill post up my confs so if anyone needs it on the future can relate to this post.

At first, you have to install some packages:
aptitude install postfix libsasl2 libsasl2-modules ca-certificates

Then, edit the /etc/postfix/main.cf as follows:

Code:
# sets gmail as relay
relayhost = [smtp.gmail.com]:587

#  use tls
smtp_use_tls=yes

# use sasl when authenticating to foreign SMTP servers
smtp_sasl_auth_enable = yes

# path to password map file
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

# list of CAs to trust when verifying server certificate
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

# eliminates default security options which are imcompatible with gmail
smtp_sasl_security_options =

if you want more info, you can also add for debug purposes:
Code:
#debug_peer_list = smtp.gmail.com
#debug_peer_level = 3

Then, you have to put your gapps account credentials on the password file, and secure it:
#vi /etc/postfix/sasl_passwd
Code:
[smtp.gmail.com]:587   email@gapps.domain.com:password
#postmap /etc/postfix/sasl_passwd
#rm /etc/postfix/sasl_passwd

then restart the service, and send a test email:
#service postfix restart
#echo test | mail -s testing email@address.com

and you can monitor whats happening with:
#tail -f /var/log/mail.log

Also, if you want to change the sending addres, on proxmox you can change it on Datacenter / options / email to the email you want.


hope its helpfun for anyone using google apps mail service
 
This worked perfectly! Thanks for your effort and time.

Why is it that creators/maintainers of great products like this think that leaving a crucial part of the system (like sending notifications) is not "part of their application"? When setting up other commercial applications - there is typically an interface from the program that lets you set this stuff up rather handily - they don't refer you to some other thing you need to download, learn to use or install to make this part of their product work. At the very least, I would think ProXmoX could add something simple like a configuration interface for sendemail rather than an entire sendmail or postfix install and include it in the build leaving a more complex set up for those individuals that want a more complex setup.

Cannot help but think it tends to lead to folks just not using the original product.
 
  • Like
Reactions: Tommmii and Tom7320
Hi!

@Carlos: Thanks a lot for your post! It worked and helped a lot!

@David: I totally agree! I really appreciate using Proxmox VE. But I think as a professional solution, it definitely should have GUI support for essential things like sending mails, monitor HDD SMART or configure attached UPS....

Regards

Tom
 
  • Like
Reactions: Carlos Gomes
PS:

I would suggest adding two more things to the mentioned configuration:

Add a line to the file /etc/aliases:

Code:
root: your_real_mailaddress@your_provider.com

Update the database:

Code:
# newaliases

Now all root mails will be redirected to you via BCC. If you actually want "root" to be substituted with your external mail address (which is nicer in my opinion) add a line to /etc/postfix/main.cf

Code:
smtp_generic_maps = hash:/etc/postfix/generic

Create a file /etc/postfix/generic:

Code:
root your_real_mailaddress@your_provider.com

Update the database and restart postfix:

Code:
# postmap /etc/postfix/generic
# /etc/init.d/postfix restart

Regards

Tom
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!