0

As google cloud don't allow sending emails from VMs port 25 is blocked, I am using third party service Mailjet to with VM to send email, I am using docker container to install postfix and test working of Mailjet .

  1. Configured relay with Postfix successfully using this google documentation
  2. Able to send an email using echo 'Test passed.' | mail -s Test-Email EMAIL@EXAMPLE.COM , Mail is recived by Mailjet .

Problem *When sending test mail echo 'Test passed.' | mail -s Test-Email username@gmail.com mail is sent to Mailjet

problem is it is sent using root@mydomain.com

, which Mailjet is asking me to confirm, I configured support@mydomain.com in Mailjet want same support@mydomain.com in place of root@mydomain.com, Tried many solutions didn't work ,

Want to change sending address root@mydomain.com = support@mydomain.com*

Attached Configuration and Logs

/var/log/mail.log

May 14 17:57:38 mydomain postfix/qmgr[1446]: 891A3199F: removed
May 14 18:04:51 mydomain postfix[2587]: Postfix is running with backwards-compatible default settings
May 14 18:04:51 mydomain postfix[2587]: See http://www.postfix.org/COMPATIBILITY_README.html for details
May 14 18:04:51 mydomain postfix[2587]: To disable backwards compatibility use "postconf compatibility_level=2" and "postfix reload"
May 14 18:04:51 mydomain postfix/postfix-script[2593]: fatal: the Postfix mail system is already running
May 14 18:04:58 mydomain postfix[2709]: Postfix is running with backwards-compatible default settings
May 14 18:04:58 mydomain postfix[2709]: See http://www.postfix.org/COMPATIBILITY_README.html for details
May 14 18:04:58 mydomain postfix[2709]: To disable backwards compatibility use "postconf compatibility_level=2" and "postfix reload"
May 14 18:04:58 mydomain postfix/postfix-script[2715]: fatal: the Postfix mail system is already running
May 14 18:05:17 mydomain postfix[2831]: Postfix is running with backwards-compatible default settings
May 14 18:05:17 mydomain postfix[2831]: See http://www.postfix.org/COMPATIBILITY_README.html for details
May 14 18:05:17 mydomain postfix[2831]: To disable backwards compatibility use "postconf compatibility_level=2" and "postfix reload"
May 14 18:05:17 mydomain postfix/postfix-script[2837]: fatal: the Postfix mail system is already running
May 14 18:05:30 mydomain postfix/pickup[1445]: 4506C2086: uid=0 from=<root@mydomain.com>
May 14 18:05:30 mydomain postfix/cleanup[2845]: 4506C2086: message-id=<20180514180530.4506C2086@mydomain.com>
May 14 18:05:30 mydomain postfix/qmgr[1446]: 4506C2086: from=<root@mydomain.com>, size=352, nrcpt=1 (queue active)
May 14 18:05:30 mydomain postfix/smtp[2847]: warning: database /etc/postfix/generic.db is older than source file /etc/postfix/generic
May 14 18:05:31 mydomain postfix/smtp[2847]: 4506C2086: to=<username@gmail.com>, relay=in.mailjet.com[104.xxx.xx.xx]:2525, delay=1.7, delays=0.02/0.01/1.3/0.33, dsn=2.0.0, status=sent (250 OK queued as 64ced0eb-ab23-498b-be32-2c267c128ce4)
May 14 18:05:31 mydomain postfix/qmgr[1446]: 4506C2086: removed

grep postfix /var/log/syslog

May 14 17:57:38 mydomain postfix/qmgr[1446]: 891A3199F: removed
May 14 18:04:51 mydomain postfix[2587]: Postfix is running with backwards-compatible default settings
May 14 18:04:51 mydomain postfix[2587]: See http://www.postfix.org/COMPATIBILITY_README.html for details
May 14 18:04:51 mydomain postfix[2587]: To disable backwards compatibility use "postconf compatibility_level=2" and "postfix reload"
May 14 18:04:51 mydomain postfix/postfix-script[2593]: fatal: the Postfix mail system is already running
May 14 18:04:58 mydomain postfix[2709]: Postfix is running with backwards-compatible default settings
May 14 18:04:58 mydomain postfix[2709]: See http://www.postfix.org/COMPATIBILITY_README.html for details
May 14 18:04:58 mydomain postfix[2709]: To disable backwards compatibility use "postconf compatibility_level=2" and "postfix reload"
May 14 18:04:58 mydomain postfix/postfix-script[2715]: fatal: the Postfix mail system is already running
May 14 18:05:17 mydomain postfix[2831]: Postfix is running with backwards-compatible default settings
May 14 18:05:17 mydomain postfix[2831]: See http://www.postfix.org/COMPATIBILITY_README.html for details
May 14 18:05:17 mydomain postfix[2831]: To disable backwards compatibility use "postconf compatibility_level=2" and "postfix reload"
May 14 18:05:17 mydomain postfix/postfix-script[2837]: fatal: the Postfix mail system is already running
May 14 18:05:30 mydomain postfix/pickup[1445]: 4506C2086: uid=0 from=<root@mydomain.com>
May 14 18:05:30 mydomain postfix/cleanup[2845]: 4506C2086: message-id=<20180514180530.4506C2086@mydomain.com>
May 14 18:05:30 mydomain postfix/qmgr[1446]: 4506C2086: from=<root@mydomain.com>, size=352, nrcpt=1 (queue active)
May 14 18:05:30 mydomain postfix/smtp[2847]: warning: database /etc/postfix/generic.db is older than source file /etc/postfix/generic
May 14 18:05:31 mydomain postfix/smtp[2847]: 4506C2086: to=<username@gmail.com>, relay=in.mailjet.com[104.199.96.85]:2525, delay=1.7, delays=0.02/0.01/1.3/0.33, dsn=2.0.0, status=sent (250 OK queued as 64ced0eb-ab23-498b-be32-2c267c128ce4)
May 14 18:05:31 mydomain postfix/qmgr[1446]: 4506C2086: removed

cat /etc/postfix/main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
virtual_alias_maps = hash:/etc/postfix/virtual

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, mydomain.com, localhost.com, localhost
relayhost = in.mailjet.com:2525
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
#default_transport = error
#relay_transport = error
inet_protocols = all
smtp_tls_security_level = encrypt
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_generic_maps = hash:/etc/postfix/generic

cat /etc/aliases

# See man 5 aliases for format
    postmaster:    root
    root: support@mydomain.com

cat /etc/mailname

mydomain.com

I am new to postfix configuration after trying many solution not able to find soultion thanks for any help.

twister_void
  • 71
  • 1
  • 7
  • The Postfix log entries you posted don't appear to be relevant. Please post relevant log entries. Also please explain what is happening. – Michael Hampton May 15 '18 at 00:18
  • Yes, how are you generating the email? – Tim May 15 '18 at 01:36
  • @MichaelHampton updated issue with postfix log and more description hope it helps – twister_void May 15 '18 at 04:36
  • @varlogtim , I didn't understand what exctaly you asked i updated my question , I am invoking email from this command `echo 'Test passed.' | mail -s Test-Email EMAIL@EXAMPLE.COM` – twister_void May 15 '18 at 04:38
  • 1
    Presumably you're running that command as root, so it's not entirely by design that e-mail would be coming from `root@example.com`. – womble May 15 '18 at 05:49
  • Send the mail as the `support` user instead of as `root`. – Michael Hampton May 15 '18 at 05:53
  • @womble I am having only one user which is root because I am in docker environment. – twister_void May 15 '18 at 06:06
  • @MichaelHampton How i can user mail as `support` instead of `root` – twister_void May 15 '18 at 06:07
  • @twister_void Your application should set the from address. – Michael Hampton May 15 '18 at 06:09
  • Running in Docker does not mean running as root, and it is just as bad an idea to run something as root in Docker as it is the rest of the time. Further, whether you're in Docker or not doesn't change the fact that if you send mail as root, it's going to be sent as root. – womble May 15 '18 at 09:55
  • @womble Nice I got your point so if I am running as `root` it will send me a mail using `root`, So if I create a new username `support`, and send email using `support` account then I think mail will be sent as `support` – twister_void May 15 '18 at 11:02

0 Answers0