2

How to configure SMTP client (Ubuntu desktop) to use Gmail SMTP server to send email from my desktop using postfix.

This is how we login to company provided email. we login to gmail.com using myemail@companydomain.com and password. So I understanding that our email server is with gmail.

I have configured postfix to send email using smtp.gmail.server to send email from local computer. I followed https://kifarunix.com/configure-postfix-to-use-gmail-smtp-on-ubuntu-18-04/ to setup postfix. Then trying to send email via commandline using my gmail (mygmail@gmail.com) account and company account (myemail@companydomain.com)

echo "mail test"|mailx -s "Subject test" myemail@gmail.com
echo "mail test"|mailx -s "Subject test" myemail@compnaydomain.com

The postfix configuration using "dpkg-reconfigure postfix"

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
compatibility_level = 2
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = ThinkPad-E470
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = ThinkPad-E470, gmail.com, ThinkPad-E470, localhost.localdomain, localhost, companydomain.com
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
smtpd_tls_auth_only = no
smtpd_tls_key_file = /etc/ssl-certs/mail.companydomain.com.key
smtpd_tls_cert_file = /etc/ssl-certs/mail.companydomain.com.crt
smtpd_tls_CAfile = /etc/ssl-certs/cacert.pem
tls_random_source = dev:/dev/urandom

In the /var/log/mail/log, seeing the below non delivery notification when email to myemail@gmail.com.

May  7 13:41:58 ThinkPad-E470 postfix/pickup[6321]: 5962528214FB: uid=0 from=<root@ThinkPad-E470>
May  7 13:41:58 ThinkPad-E470 postfix/cleanup[6695]: 5962528214FB: message-id=<20190507174158.5962528214FB@ThinkPad-E470>
May  7 13:41:58 ThinkPad-E470 postfix/qmgr[6322]: 5962528214FB: from=<root@ThinkPad-E470>, size=375, nrcpt=1 (queue active)
May  7 13:41:58 ThinkPad-E470 postfix/local[6697]: 5962528214FB: to=<myemail@companydomain.com>, relay=local, delay=0.38, delays=0.29/0.01/0/0.08, dsn=5.1.1, status=bounced (unknown user: "myemail")
May  7 13:41:58 ThinkPad-E470 postfix/cleanup[6695]: A840828214FF: message-id=<20190507174158.A840828214FF@ThinkPad-E470>
May  7 13:41:58 ThinkPad-E470 postfix/bounce[6698]: 5962528214FB: sender non-delivery notification: A840828214FF
May  7 13:41:58 ThinkPad-E470 postfix/qmgr[6322]: A840828214FF: from=<>, size=2355, nrcpt=1 (queue active)
May  7 13:41:58 ThinkPad-E470 postfix/local[6697]: A840828214FF: to=<root@ThinkPad-E470>, relay=local, delay=0.26, delays=0.21/0/0/0.05, dsn=2.0.0, status=sent (delivered to mailbox) 
May  7 13:41:58 ThinkPad-E470 postfix/qmgr[6322]: 5962528214FB: removed
May  7 13:41:59 ThinkPad-E470 postfix/qmgr[6322]: A840828214FF: removed

In the /var/log/mail/log, seeing the below non delivery notification when email to myemail@companydomain.com.

May  7 14:01:07 ThinkPad-E470 postfix/pickup[6321]: 798E828214FB: uid=0 from=<root@ThinkPad-E470>
May  7 14:01:07 ThinkPad-E470 postfix/cleanup[6873]: 798E828214FB: message-id=<20190507180107.798E828214FB@ThinkPad-E470>
May  7 14:01:07 ThinkPad-E470 postfix/qmgr[6322]: 798E828214FB: from=<root@ThinkPad-E470>, size=375, nrcpt=1 (queue active)
May  7 14:01:07 ThinkPad-E470 postfix/local[6875]: 798E828214FB: to=<myemail@companydomain.com>, relay=local, delay=0.33, delays=0.24/0/0/0.09, dsn=5.1.1, status=bounced (unknown user: "myemail")
May  7 14:01:07 ThinkPad-E470 postfix/cleanup[6873]: BDB3028214FF: message-id=<20190507180107.BDB3028214FF@ThinkPad-E470>
May  7 14:01:07 ThinkPad-E470 postfix/bounce[6876]: 798E828214FB: sender non-delivery notification: BDB3028214FF
May  7 14:01:07 ThinkPad-E470 postfix/qmgr[6322]: BDB3028214FF: from=<>, size=2355, nrcpt=1 (queue active)
May  7 14:01:07 ThinkPad-E470 postfix/local[6875]: BDB3028214FF: to=<root@ThinkPad-E470>, relay=local, delay=0.23, delays=0.17/0/0/0.06, dsn=2.0.0, status=sent (delivered to mailbox) 
May  7 14:01:08 ThinkPad-E470 postfix/qmgr[6322]: 798E828214FB: removed
May  7 14:01:08 ThinkPad-E470 postfix/qmgr[6322]: BDB3028214FF: removed

I do not know how email and proxy and relay servers work. I could not understand how my company email server is configured and to setup postfix to use gmail smtp server from my desktop machine.

The self-signed ssl key and certificate and CA certs are created for postfix locally for domain companydomain.com.

How to configure postfix to use my smtp server from ubuntu client?

  • myemail@gmail.com is not the same as mygmail@gmail.com – Edo Akse May 8 at 14:09
  • Edo Akse@ I tried to use two of my email accounts GMAIL.COM (personal) and COMPANYDOMAIN.COM (corporate). – arunp May 9 at 19:11
0

I believe the problem is the presence of gmail.com and companydomain.com in mydestination.

In the mailx command the last argument is the recipient address. As those domains are listed in mydestination what happens is that you're sending the mails to your local server, which fails because those users don't exist locally.

  • It could be the case, because it worked when send to different email with different domain. – arunp May 9 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.