使用自定义发件人:字段发送电子邮件

使用自定义发件人:字段发送电子邮件

我真的不喜欢邮件配置,但不知何故我设法配置了 exim4 并且它确实发送了电子邮件。我花了很多时间在上面,尽管我什至都数不清。 (我不知道为什么它如此复杂,而需求通常非常相似:拥有应该用于实际发送电子邮件的电子邮件地址 - 这几乎就是一切,不考虑安全主题,这主要与身份验证有关)。

当我发送电子邮件时,我已自动将 FROM 字段设置为“root”(Linux 用户)。我想要一个自定义字段(例如“联系我”),但我在互联网上找不到任何如何执行此操作的答案。

其次,有人说使用 Linux 用户与电子邮件地址相关并不是一件好事,例如: http://t-machine.org/index.php/2014/06/27/webmail-on-your-debian-server-exim4-dovecot-roundcube/ 但我发现教程使用了它们。我没有使用上面网址中的数据库,但我仍然希望没有与电子邮件相关的 Linux 用户 - 这是很难实现的吗?我怎么能这样做呢?

这是 /etc/exim4/update-exim4.conf.conf 内容:

# /etc/exim4/update-exim4.conf.conf
#
# Edit this file and /etc/mailname by hand and execute update-exim4.conf
# yourself or use 'dpkg-reconfigure exim4-config'
#
# Please note that this is _not_ a dpkg-conffile and that automatic changes
# to this file might happen. The code handling this will honor your local
# changes, so this is usually fine, but will break local schemes that mess
# around with multiple versions of the file.
#
# update-exim4.conf uses this file to determine variable values to generate
# exim configuration macros for the configuration file.
#
# Most settings found in here do have corresponding questions in the
# Debconf configuration, but not all of them.
#
# This is a Debian specific file

dc_eximconfig_configtype='internet'
dc_other_hostnames='url.com; mail.url.com; url; localhost;  localhost.localdomain'
dc_local_interfaces='127.0.0.1; my_ip'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='true'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='maildir_home'

无论如何,我将我的域名替换为 url,将 ip 替换为 my_ip。

/etc/email-addresses 非常短:

root: [email protected]

答案1

您需要告诉您想要使用的名称(目前很可能mail在 中查找)。/etc/passwd当然,您也可以更改用户全名/etc/passwd(例如,via ,并且您确实不应该以root身份发送邮件!chfn -f 'New Name' user

对于 Heirloom 邮件,您可以使用from环境变量、其 mailrc 配置文件或-r选项。就像其中之一:

echo 'This is a test.' | mail -r 'Contact Me <root>' \ 
                              -s 'Testing' '[email protected]'   # using -r argument

# ... or ...

echo 'This is a test.' | from='Contact Me <root>' mail \
                              -s 'Testing' '[email protected]'   # env var 'email'

对于 的其他版本mail,请检查它们的联机帮助页。

答案2

From: 地址中的描述性文本取自密码文件。您可以使用该chfn命令来更改此设置。尝试以下命令(根据需要更改全名和用户 ID):

sudo chfn -f "Contact me" root

理想情况下,您将拥有 root 的别名来/etc/aliases指定谁应该接收发送给 root 的邮件。这可能是您的用户 ID,任何发送到 root 的邮件都将发送到您的邮箱。

添加相同的别名/etc/email-addresses将更改“发件人”字段中使用的地址。这应该是一个有效的地址,因为回复将发送到该地址。

相关内容