我有一个运行postfix的ubuntu服务器.它不是我的域的邮件服务器.
每当cron作业运行root时,输出邮件不会在本地传递,而是通过主邮件服务器发送到root@mydomain.com.这不是我想要的.
我希望root用户的邮件可以在本地发送或转发到anothermail@anotherdomain.com.
我已经尝试修改~root / .forward和/ etc / aliases(以及运行newaliases),但没有任何帮助(我猜这些文件只在postfix尝试在本地传递时检查).
我能做什么?
这是/etc/postfix/main.cf:
- smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
- biff = no
- append_dot_mydomain = no
- readme_directory = no
- 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
- myhostname = linux1.mydomain.com
- alias_maps = hash:/etc/aliases
- alias_database = hash:/etc/aliases
- myorigin = /etc/mailname
- mydestination = linux1.mydomain.com,localhost.linux1.mydomain.com,localhost
- relayhost = my.isps.relayhost.com
- mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
- mailBox_size_limit = 0
- recipient_delimiter = +
- inet_interfaces = loopback-only
编辑:
将邮件发送到root时,会进入/var/log/mail.log:
- Mar 7 09:39:17 linux1 postfix/pickup[31381]: F3B9C98025E: uid=1000 from=<ct>
- Mar 7 09:39:18 linux1 postfix/cleanup[31556]: F3B9C98025E: message-id=<20130307083917.F3B9C98025E@linux1.mydomain.com>
- Mar 7 09:39:18 linux1 postfix/qmgr[28525]: F3B9C98025E: from=<ct@mydomain.com>,size=283,nrcpt=1 (queue active)
- Mar 7 09:39:18 linux1 postfix/smtp[31558]: F3B9C98025E: to=<root@mydomain.com>,orig_to=<root>,relay=my.isps.relayhost.com[<IP address omitted>]:25,delay=0.72,delays=0.19/0.02/0.27/0.25,dsn=2.0.0,status=sent (250 Ok: queued as A97F5D8126)
- Mar 7 09:39:18 linux1 postfix/qmgr[28525]: F3B9C98025E: removed
回声测试| mail -s test root
/ etc / mailname的内容是:
- mydomain.com
/ etc / aliases的内容是:
- root: anothermail@anotherdomain.com
- postmaster: root
其中anothermail@anotherdomain.com是我希望将root邮件转发到的地方.
/ etc / hosts的内容实际上让我感到惊讶:
- 127.0.0.1 localhost
- 127.0.1.1 linux1.mylinux.mydomain.com linux1
其中“mylinux”是linux1作为虚拟机运行的主机操作系统的主机名.我不确定“mylinux”是如何进入那里的. (但这真的是我问题的原因吗?)