0

I have set up postfix to relay proxmox messages through my gmail account and used aliases to forward all my root email to an outside address. When using sendmail command the email can be seen in the sent folder of gmail with the To: field empty and Bcc: is my outside address. When using mail -s the email is seen in gmail sent folder with the To: field as the original root email and Bcc: is my outside address.

Shouldn't my forwarding address replace root@pve.home.com in the To: field instead of Bcc: and stop sending to root@pve.home.com altogether?

Test commands for root email

# echo -e "Subject:Hello World \n\n Testing email\n" | sendmail root
# echo "testing" | mail -s "test message" root

Log File

Dec 29 12:56:13 pve postfix/pickup[32080]: DB1E662DFA: uid=0 from=<root>
Dec 29 12:56:13 pve postfix/cleanup[32097]: DB1E662DFA: message-id=<20171229175613.DB1E662DFA@pve.home.com>
Dec 29 12:56:13 pve postfix/qmgr[32081]: DB1E662DFA: from=<root@pve.home.com>, size=390, nrcpt=1 (queue active)
Dec 29 12:56:13 pve postfix/cleanup[32097]: E13A162DF8: message-id=<20171229175613.DB1E662DFA@pve.home.com>
Dec 29 12:56:13 pve postfix/local[32099]: DB1E662DFA: to=<root@pve.home.com>, orig_to=<root>, relay=local, delay=0.04, delays=0.03/0.01/0/0, dsn=2.0.0, status=sent (forwarded as E13A162DF8)
Dec 29 12:56:13 pve postfix/qmgr[32081]: E13A162DF8: from=<root@pve.home.com>, size=515, nrcpt=1 (queue active)
Dec 29 12:56:13 pve postfix/qmgr[32081]: DB1E662DFA: removed
Dec 29 12:56:13 pve postfix/smtp[32100]: connect to smtp.gmail.com[2607:f8b0:4001:c1d::6c]:587: Network is unreachable
Dec 29 12:56:14 pve postfix/smtp[32100]: E13A162DF8: to=<someone@icloud.com>, orig_to=<root>, relay=smtp.gmail.com[74.125.126.109]:587, delay=0.85, delays=0/0.03/0.37/0.45, dsn=2.0.0, status=sent (250 2.0.0 OK 1514570174 f126sm11045770ioa.84 - gsmtp)
Dec 29 12:56:14 pve postfix/qmgr[32081]: E13A162DF8: removed

Dec 29 12:59:40 pve postfix/pickup[32080]: D6C9362DFA: uid=0 from=<root>
Dec 29 12:59:40 pve postfix/cleanup[32429]: D6C9362DFA: message-id=<20171229175940.D6C9362DFA@pve.home.com>
Dec 29 12:59:40 pve postfix/qmgr[32081]: D6C9362DFA: from=<root@pve.home.com>, size=280, nrcpt=1 (queue active)
Dec 29 12:59:40 pve postfix/cleanup[32429]: DDD4D62DF8: message-id=<20171229175940.D6C9362DFA@pve.home.com>
Dec 29 12:59:40 pve postfix/local[32431]: D6C9362DFA: to=<root@pve.home.com>, orig_to=<root>, relay=local, delay=0.05, delays=0.03/0.01/0/0.01, dsn=2.0.0, status=sent (forwarded as DDD4D62DF8)
Dec 29 12:59:40 pve postfix/qmgr[32081]: DDD4D62DF8: from=<root@pve.home.com>, size=405, nrcpt=1 (queue active)
Dec 29 12:59:40 pve postfix/qmgr[32081]: D6C9362DFA: removed
Dec 29 12:59:41 pve postfix/smtp[32432]: connect to smtp.gmail.com[2607:f8b0:4001:c1d::6c]:587: Network is unreachable
Dec 29 12:59:41 pve postfix/smtp[32432]: DDD4D62DF8: to=<someone@icloud.com>, orig_to=<root>, relay=smtp.gmail.com[74.125.126.109]:587, delay=0.93, delays=0.01/0.02/0.52/0.38, dsn=2.0.0, status=sent (250 2.0.0 OK 1514570381 a69sm13573861itc.18 - gsmtp)
Dec 29 12:59:41 pve postfix/qmgr[32081]: DDD4D62DF8: removed

aliases

root: someone@icloud.com

postmaster: root
nobody: root
hostmaster: root
webmaster: root
www:root

main.cf

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

myhostname=pve.home.com

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
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

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, localhost.$mydomain, localhost
#relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
inet_interfaces = loopback-only
recipient_delimiter = +

# 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/Equifax_Secure_CA.pem
smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cache
smtp_tls_session_cache_timeout = 3600s

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

hosts

127.0.0.1 localhost.localdomain localhost
127.0.1.1 pve.home.com pve pvelocalhost

# The following lines are desirable for IPv6 capable hosts

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

mailname

pve.home.com
  • Rephrased. It means should it replace the root@pve.home.com with someone@icloud.com in the to: field and not send to both? – Aaron Dec 29 '17 at 18:58
1

Addresses are not rewritten by default; the Sendmail feature for this is genericstable which Postfix calls generic(5) so in theory adding

smtp_generic_maps = hash:/etc/postfix/generic

to your main.cf and then adding entries to /etc/postfix/generic such as

root@pve.home.com someone@icloud.com

and then running postmap /etc/postfix/generic and restarting Postfix should cause a rewrite of addresses. (This can be complicated by the distinction between envelope addresses used by mail transfer agents such as Postfix and body addresses present in the message itself...)

In the | sendmail case you should supply an appropriate To address header along with the Subject, or instead use a mail user agent (such as mail) that handles those details for you.

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.