ChatGPT解决这个技术问题 Extra ChatGPT

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

关闭。此问题不符合 Stack Overflow 准则。它目前不接受答案。我们不允许在 Stack Overflow 上提出有关专业服务器或网络相关基础设施管理的问题。您可以编辑问题,使其成为 Stack Overflow 的主题。 8年前关闭。改进这个问题

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

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

我已经这样做了:

sudo apt-get install sendmail

然后

sudo sendmailconfig

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

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

S
Stephen Ostermiller

当您输入 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 之前。确保更新您的 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 和 I:user
如果其他人感到困惑,sendmail.mc 文件中的字符串需要采用 BACKTICK + 您的文本 + 单引号的形式。
b
brma

经过一次小的编辑后,我得到了最佳答案(尚无法回复)

这对我不起作用:

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
这是“特征”而不是“特征”,请检查您的复制/粘贴
您必须将其粘贴到 sendmail.cf 中的不同位置(我将它放在邮件程序上方,但我仍然没有收到邮件)
f
flyrain

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

关注公众号,不定期副业成功案例分享
关注公众号

不定期副业成功案例分享

领先一步获取最新的外包任务吗?

立即订阅