Postfix relay server not accepting Moodle mail

Postfix relay server not accepting Moodle mail

by Arnoldo Diaz -
Number of replies: 3

I've installed a Postfix relay server (Debian 10) to send mail from Moodle 3.9 to the relay server, and then trough a Gmail account. I do this because sending mail from Moodle directly to a gmail account exceeds the messages daily limit (I need to send between 4,000 and 8,000 daily messages). I followed the discussion of this thread:  https://moodle.org/mod/forum/discuss.php?d=390369, and installed the postfix relay server following the instructions of this link:  https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/.

I am able to send mail from the relay server to the gmail account (a G suite account). That is, every mail sent from the relay server is sent to the final destination through the gmail account. However, I am not able to send mail from Moodle to the relay account. Checking /var/log/mail.log I got this:

connect from my.relayserver.domain[myIPaddress]

disconnect from my.relayserver.domain[myIPaddress] ehlo=2 starttls=1 quit=1 commands=4

I've used ports 25 and 587 with same results. I've been searching for a solution for two weeks with no luck.

I'll appreciate any help you can provide, specially if someone uses a similar approach to send mail through a G suite account to avoid the problem caused by the limited number pf messages set per gmail account.

Average of ratings: -
In reply to Arnoldo Diaz

Re: Postfix relay server not accepting Moodle mail

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
What are the settings on Moodle? Site administration > Server > Email > Outgoing mail configuration:
smtphosts, smtpsecure, smtpauthtype, smtpuser, smtppass (edited), smtpmaxbulk.

Does Postfix run on the same server as Moodle (localhost)? What are its corresponding settings. Thinks like smtpd_relay_restrictions, relayhost, mynetworks in /etc/postfix/main.cf?

P.S. Saw that you tried to resurrect https://moodle.org/mod/forum/discuss.php?d=390369#p1653770 without success. Yes, this new discussion is the right thing. You may want to put a "continued in" notice in the other thread pointing to this discussion.

P.P.S. Are you sure your Gmail account allows upto 8,000 e-mail per day? If not, you have to make your Postfix "relay" a real SMTP server, i.e. send e-mails straight to the recipient MX.
In reply to Visvanath Ratnaweera

Re: Postfix relay server not accepting Moodle mail

by Arnoldo Diaz -
Dear Visvanath, thanks a lot for your interest in my post and for replaying it. The setting on Moodle are:
SMTP server: my.realy.server domain
SMTP security: TLS
SMTP auth type: LOGIN
SMTP user name: user name of relay server (which is also in /etc/postfix/sasl_passwd)
SMTP user password. password of user name of relay server (which is also in /etc/postfix/sasl_passwd)
SMTP max bulk: 10

The postfix server is not installed on the same server where Moodle is. Both run on Debian 10. The parameters defined in /etc/postfix/main.c are:
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
myhostname = my.relayserver.domain
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
#myorigin = /etc/mailname
#mydestination = $myhostname, localhost.my.relayserver.domain, localhost
mydestination = $myhostname, localhost.$mydomain
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_tls_key_file = /etc/letsencrypt/live/my.relayserver.domain/privkey.pem
smtpd_tls_cert_file = /etc/letsencrypt/live/my.relayserver.domain/cert.pem
smtpd_tls_CAfile = /etc/letsencrypt/live/my.relayserver.domain/chain.pem

smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
mynetworks = my.relay.server.ip/32
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

I've tried different configurations without success.

Regarding the maximum amount of mails allowed by Google on G suits relay accounts, according to this link, is at least 10k per day:

https://support.google.com/a/answer/2956491?hl=en

I am able to send mails from the relay server to its final destination through the gmail account. However, when I try to send them from the Moodle server to the relay server, I get almost always the following messages on the really server (in /var/log/mail.log):

connect from my.relayserver.domain[myIPaddress]

disconnect from my.relayserver.domain[myIPaddress] ehlo=2 starttls=1 quit=1 commands=4

Thanks again for your support.
In reply to Arnoldo Diaz

Re: Postfix relay server not accepting Moodle mail

by Arnoldo Diaz -
Dear @Visvanath Ratnaweera, after reading your reply and after reading a message that kindly sent to me @Emma Richardson, I installed the relay server in the same physical server where Moodle is running. Now everything is working great. Thanks to both of you for your support.