是否可以使用 ssmtp 重写 TO:字段?

是否可以使用 ssmtp 重写 TO:字段?

我正在尝试使用 重写TO:已发送的电子邮件中的标题ssmtp

我已将邮件配置为root通过 发送ssmtp(通过在 处创建符号链接/etc/sendmail)。

它被重定向到/etc/aliases条目,但 TO:标头始终是用户本身,在本例中为“TO:root”。

SMTP 服务器拒绝此别名。我想将 TO: 字段重写为可配置的电子邮件地址。

我已经配置了:/etc/aliases,,/etc/ssmtp/revaliases并且/etc/ssmtp/ssmtp.conf正如我所料可以工作。

这可能吗ssmtp

[更新]

设置:

yum -y install ssmtp

service sendmail stop
chkconfig --levels 2345 sendmail off
chkconfig --del sendmail
export tmpsm=$(which sendmail)
mv $tmpsm $(echo $tmpsm.bak)

ln -s $(which ssmtp) $tmpsm

groupadd nogroup
useradd ssmtp -g nogroup -s /sbin/nologin -d /nonexistent -c "sSMTP pseudo-user"
chown ssmtp:wheel /etc/ssmtp/ #http://en.wikipedia.org/wiki/Wheel_(Unix_term)
chmod 4750 /etc/ssmtp/ #https://en.wikipedia.org/wiki/Setuid
chown ssmtp:wheel /etc/ssmtp/ /etc/ssmtp/ssmtp.conf
chmod 640 /etc/ssmtp/ssmtp.conf

chown ssmtp:nogroup $(which ssmtp)
chmod 4555 $(which ssmtp)

sed s/root=postmaster/#root=postmaster/ -i /etc/ssmtp/ssmtp.conf
sed s/mailhub=mail/#mailhub=mail/ -i /etc/ssmtp/ssmtp.conf
echo "[email protected]" >> /etc/ssmtp/ssmtp.conf #will route anything that's sent to any user with a UID under 500 (check /etc/passwd) to [email protected]
echo "mailhub=smtp.stackoverflown.com:587" >> /etc/ssmtp/ssmtp.conf 
echo "[email protected]" >> /etc/ssmtp/ssmtp.conf 
echo "AuthPass=XXXXXXXXX" >> /etc/ssmtp/ssmtp.conf 
echo "[email protected]" >> /etc/ssmtp/ssmtp.conf  #will rewrite the domain when destined for a domain
echo "[email protected]" >> /etc/ssmtp/ssmtp.conf 
echo "FromLineOverride=YES" >> /etc/ssmtp/ssmtp.conf 
echo "UseTLS=YES" >> /etc/ssmtp/ssmtp.conf 
echo "UseSTARTTLS=Yes" >> /etc/ssmtp/ssmtp.conf 


echo "root:[email protected]" >> /etc/ssmtp/revaliases
echo "seccubus:[email protected]" >> /etc/ssmtp/revaliases


#setup send as alias
echo 'root: [email protected]' >> /etc/aliases
echo 'seccubus: [email protected]' >> /etc/aliases
newaliases

测试:

yum -y install mailx

#test baseline:
echo "test" | mail -v -s "$(date)" [email protected]
#test sending to a local user:
echo $(netstat -apn | grep :) | mail -v -s "$(date)" root #<-------------------FAILS to send due to SERVER specific policy!  because "TO: root"

#check logs:
tail -f /var/log/maillog

相关内容