在我的 Ubuntu 14.04 桌面上,我按照以下步骤使用 Postfix 设置本地邮件本指南确切地。
是否可以保留本地消息传递功能,同时添加外部 (gmail) 帐户以向外界发送命令行电子邮件?如果可以,该怎么做?
编辑 - 基本上,我希望 cron 消息是本地的,并且能够通过 Gmail 发送命令行电子邮件。
编辑-当前配置:
$ postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
default_transport = error
home_mailbox = Maildir/
inet_interfaces = loopback-only
mailbox_size_limit = 0
mydestination = HP-Pavilion-dv7.laptop, HP-Pavilion-dv7, localhost.localdomain, localhost
myhostname = HP-Pavilion-dv7
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relay_transport = error
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
答案1
您必须Sender-Dependent SASL authentication
在 Postfix 中进行配置。请将以下几行添加到您的main.cf
#/etc/postfix/main.cf
#...
smtp_sender_dependent_authentication = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
relayhost = smtp.gmail.com:587
smtp_tls_security_level = may
smtp_sasl_security_options =
#...
并/etc/postfix/sasl_passwd
使用以下内容创建。
[email protected] [email protected]:password1
[email protected] [email protected]:password2
执行postmap /etc/postfix/sasl_passwd
并重新加载 postfix。
参考:Postfix 文档
您的所有local
邮件都将像以前一样投递。如果您使用以下命令[email protected]
向[email protected]
echo "Hi Everyone"|mail -s "Test email" -r "[email protected]" [email protected]
然后您的 postfix 服务器将使用[email protected]
中配置的密码进行身份验证/etc/postfix/sasl_passwd
。希望对您有所帮助。