0

I have server proxmox1 configured to send emails through GMail server. Here is the relevant part of my /etc/postfix/main.cf :

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = proxmox1
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost.$mydomain, localhost
# p1 has an IP in the range 192.168.1.0/24
mynetworks = 127.0.0.0/8 192.168.1.0/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

inet_protocols = ipv4
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_tls_security_level = encrypt
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_sasl_security_options = noanonymous

I try to send email from server p1, using mailx and the postfix server on proxmox1. Here is my .mailrc file :

set smtp=smtp://proxmox1
set from="me@mydomain.com(p1)"

And here is the command I use :

echo "Test message" | mailx -s "important mail" admin@mydomain.com

It fails because postfix on proxmox1 tries to connect on port 25 to various google mail servers (/var/log/mail.log on proxmox1) :

Apr 22 11:45:00 p1 postfix/smtp[6888]: connect to aspmx.l.google.com[142.250.27.26]:25: Connection timed out
Apr 22 11:45:30 p1 postfix/smtp[6888]: connect to alt2.aspmx.l.google.com[142.250.150.27]:25: Connection timed out
Apr 22 11:45:30 p1 postfix/smtp[6888]: connect to alt1.aspmx.l.google.com[2a00:1450:4025:c03::1a]:25: Cannot assign requested address
Apr 22 11:45:30 p1 postfix/smtp[6888]: connect to alt2.aspmx.l.google.com[2a00:1450:4010:c1c::1b]:25: Cannot assign requested address
Apr 22 11:45:30 p1 postfix/smtp[6888]: D331827596: to=<admin@mydomain.com>, relay=none, delay=179091, delays=179031/0.01/60/0, dsn=4.4.1, status=deferred (connect to alt2.aspmx.l.google.com[2a00:1450:4010:c1c::1b]:25: Cannot assign requested address)

The same command on proxmox1 gives a different log :

Apr 22 12:03:38 proxmox1 postfix/pickup[280663]: 87E1211695: uid=0 from=<root>
Apr 22 12:03:38 proxmox1 postfix/cleanup[340498]: 87E1211695: message-id=<20230422100338.87E1211695@A>
Apr 22 12:03:38 proxmox1 postfix/qmgr[280664]: 87E1211695: from=<root@A>, size=420, nrcpt=1 (queue active)
Apr 22 12:03:40 proxmox1 postfix/smtp[340500]: 87E1211695: to=<admin@mydomain.com>, relay=smtp.gmail.com[142.250.102.109]:587, delay=2.2, delays=0.1/0.11/0.75/1.2, dsn=2.0.0, status=sent (250 2.0.0 OK  1682157820 u13-20020a170906c40d00b0094aa087578csm3131703ejz.171 - gsmtp)
Apr 22 12:03:40 proxmox1 postfix/qmgr[280664]: 87E1211695: removed

It looks like the relay_host option is ignored when sending email from p1...

Any idea ?

Marc

ballatom
  • 23
  • 6
  • I solved a ip isses on my proxmox by using on every container it's own postfix and there the host was configured a relay host, and what should I say it works until today – djdomi Apr 22 '23 at 10:43
  • Mmm, thanks but my purpose was to avoid configuring postfix on each and every container. – ballatom Apr 22 '23 at 10:46
  • then allow the direct access on the host and use it within the container – djdomi Apr 22 '23 at 11:20
  • What do you mean exactly and how do you do that ? – ballatom Apr 23 '23 at 04:49
  • remove relay host from the host, as I seen, you already stated a 192.168/24 there so I assume you did it already. then just use the hosts lan ip as Mail server and it should forward to the internet – djdomi Apr 24 '23 at 03:59

0 Answers0