Sendmail: 如何在 ubuntu 上配置 sendmail?

当我在 ubuntu 上搜索 sendmail 配置时,我没有得到任何明确的答案,他们每个人都认为我知道他们在说什么,

我只是想基本配置,以启用电子邮件发送,基本上我将使用它与谷歌应用程序引擎,以启用邮件发送从开发服务器。

我已经这么做了:

sudo apt-get install sendmail

那么

sudo sendmailconfig

但我不知道上一个到底做了什么。

577097 次浏览

在键入 sudo sendmailconfig时,应该会提示您配置 sendmail。

作为参考,在配置期间更新的文件位于以下位置(如果您想手动更新它们) :

/etc/mail/sendmail.conf
/etc/cron.d/sendmail
/etc/mail/sendmail.mc

您可以通过在命令行中键入以下内容来测试 sendmail,以查看它是否被正确配置和设置:

$ echo "My test email being sent from sendmail" | /usr/sbin/sendmail myemail@domain.example

下面的代码允许您将 smtp 中继添加到 sendmail:

#Change to your mail config directory:
cd /etc/mail


#Make a auth subdirectory
mkdir auth
chmod 700 auth


#Create a file with your auth information to the smtp server
cd auth
touch client-info


#In the file, put the following, matching up to your smtp server:
AuthInfo:your.isp.net "U:root" "I:user" "P:password"


#Generate the Authentication database, make both files readable only by root
makemap hash client-info < client-info
chmod 600 client-info
cd ..

在 sendmail.mc 中添加以下代码行,但是在 之前中添加 MAILERDEFINITIONS

define(`SMART_HOST',`your.isp.net')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash -o /etc/mail/auth/client-info.db')dnl

调用创建 sendmail.cf (也可以运行 make -C /etc/mail) :

m4 sendmail.mc > sendmail.cf

重新启动 sendmail 守护进程:

service sendmail restart

我得到了最高的回答工作(还不能回复)后,一个小的编辑

这对我不起作用:

FEATURE('authinfo','hash /etc/mail/auth/client-info')dnl

每个字符串的第一个引号应该改为反勾(‘) ,如下所示:

FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl

改变之后,我跑步:

sudo sendmailconfig

我是做生意的

结合上面的两个答案,我终于使它工作。只是要小心在文件 sendmail.mc 中的 每个字符串的第一个引号是反勾(‘)

#Change to your mail config directory:
cd /etc/mail


#Make a auth subdirectory
mkdir auth
chmod 700 auth  #maybe not, because I cannot apply cmd "cd auth" if I do so.


#Create a file with your auth information to the smtp server
cd auth
touch client-info


#In the file, put the following, matching up to your smtp server:
AuthInfo:your.isp.net "U:root" "I:user" "P:password"


#Generate the Authentication database, make both files readable only by root
makemap hash client-info < client-info
chmod 600 client-info
cd ..


#Add the following lines to sendmail.mc. Make sure you update your smtp server
#The first single quote for each string should be changed to a backtick (`) like this:
define(`SMART_HOST',`your.isp.net')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl


#run
sudo sendmailconfig