sendmail:如何在 ubuntu 上配置 sendmail? [关闭]

Posted

技术标签:

【中文标题】sendmail:如何在 ubuntu 上配置 sendmail? [关闭]【英文标题】:sendmail: how to configure sendmail on ubuntu? [closed] 【发布时间】:2012-05-08 17:18:57 【问题描述】:

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

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

我已经这样做了:

sudo apt-get install sendmail

然后

sudo sendmailconfig

但我不知道最后一个实际做了什么。

【问题讨论】:

@ThiefMaster 我们不再将问题迁移到相应的 SE 站点了吗? 这个问题太老了,无法迁移(当我关闭它时已经是这样了)。 这些答案都不适合我。我发现这篇在线文章对我有用:daveperrett.com/articles/2013/03/19/… @ThiefMaster 定义“太旧”你是说 sendmail 已经过时了吗?再想想。 @PJBrunet 虽然我确实认为sendmail 已经过时(有更好的选择!),但我五年前的评论只是关于我们不会将旧问题迁移到另一个 SE 站点的事实。 【参考方案1】:

当您输入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.com

以下将允许您将 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。确保更新您的 smtp 服务器。

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

【讨论】:

在尝试最后一个命令时,我得到了这个 bash:我的测试电子邮件是从 sendmail 发送的:没有这样的文件或目录 对不起,当你说your.isp.net时,我是在里面放gmail.com还是smtp.gmail.com 还有一点不清楚的是在 AuthInfo:your.isp.net "U:root" "I:user" "P:password" 中要进行哪些替换,具体来说,如何替换 U :root 和我:用户 如果其他人感到困惑,sendmail.mc 文件中的字符串需要采用 BACKTICK + 您的文本 + 单引号的形式。 这是唯一适合我的配置:linuxconfig.org/configuring-gmail-as-sendmail-email-relay【参考方案2】:

经过一次小的编辑后,我得到了最佳答案(还不能回复)

这对我不起作用:

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

每个字符串的第一个单引号应更改为反引号 (`),如下所示:

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

更改后我运行:

sudo sendmailconfig

我在做生意:)

【讨论】:

无论我是否使用你的修复,当我调用 service sendmail restart 时,我得到 fileclass: cannot open 'ATURE(authinfo,': No such file or directory 这是“FEATURE”而不是“ATURE”,请检查您的复制/粘贴 你必须将它粘贴到 sendmail.cf 中的不同位置(我把它放在邮件程序上方,但我仍然没有收到邮件)【参考方案3】:

结合上面的两个答案,我终于使它起作用了。请注意 每个字符串的第一个单引号是文件 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

【讨论】:

我仍然无法理解 AuthInfo 这行...你能举个例子吗...??? 例如,我的客户信息只有一行,AuthInfo:smtp.gmail.com "U:username" "P:password" 仍然使用所有这些设置和 AuthInfo 我使用 smtp.gmail.com 使用来自 google.admin AuthInfo 的现有帐户进入垃圾邮件列表:smtp.gmail.com "U:root" "I:name@ domain.com" "P:password" 也试过 AuthInfo: smtp-relay.gmail.com "U:root" "I:name@domain.com" "P:password" 澄清:AuthInfo: smtp.gmail.com "U:yourusername@gmail.com" "P:yourpassword"

以上是关于sendmail:如何在 ubuntu 上配置 sendmail? [关闭]的主要内容,如果未能解决你的问题,请参考以下文章

ubuntu下的sendmail 8.14.4如何更改附件大小限制

ubuntu sendmail

linux下的sendmail如何配置??

xampp sendmail 使用 gmail 帐户,来自 ubuntu

如何使用 Zend_Mail、sendmail 和 localhost 发送电子邮件?

sendmail 在linux 中如何启动