sendmail:如何在ubuntu上配置sendmail?

UXE*_*UXE 184 ubuntu configuration sendmail

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

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

我已经这样做了:

sudo apt-get install sendmail
Run Code Online (Sandbox Code Playgroud)

然后

sudo sendmailconfig
Run Code Online (Sandbox Code Playgroud)

但我不知道最后一个人到底做了什么.

Ven*_*ice 142

键入时sudo sendmailconfig,系统应提示您配置sendmail.

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

/etc/mail/sendmail.conf
/etc/cron.d/sendmail
/etc/mail/sendmail.mc
Run Code Online (Sandbox Code Playgroud)

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

$ echo "My test email being sent from sendmail" | /usr/sbin/sendmail myemail@domain.com
Run Code Online (Sandbox Code Playgroud)

以下将允许您向sendmail添加smtp中继:

#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 ..
Run Code Online (Sandbox Code Playgroud)

添加以下行的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
Run Code Online (Sandbox Code Playgroud)

调用创建sendmail.cf(或者运行make -C /etc/mail):

m4 sendmail.mc > sendmail.cf
Run Code Online (Sandbox Code Playgroud)

重启sendmail守护进程:

service sendmail restart
Run Code Online (Sandbox Code Playgroud)

  • 有一点不清楚的是在AuthInfo中要做的替换:your.isp.net"U:root""我:用户""P:密码"具体来说,你如何替换U:root和I:user (29认同)
  • 如果其他人感到困惑,`sendmail.mc`文件中的字符串需要采用**BACKTICK**+你的文字+单引号的形式. (12认同)
  • 当我尝试最后一个命令时,我得到了这个bash:我的测试邮件是从sendmail发送的:没有这样的文件或目录 (2认同)
  • 对不起,当你说'your.isp.net`时,我在那里放了'gmail.com`或`smtp.gmail.com`吗? (2认同)
  • 这是唯一适合我的配置:https://linuxconfig.org/configuring-gmail-as-sendmail-email-relay (2认同)

brm*_*rma 35

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

这不适合我:

FEATURE('authinfo','hash /etc/mail/auth/client-info')dnl
Run Code Online (Sandbox Code Playgroud)

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

FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl
Run Code Online (Sandbox Code Playgroud)

改变之后我运行:

sudo sendmailconfig
Run Code Online (Sandbox Code Playgroud)

而我在做生意:)

  • 它的"FEATURE"不是"ATURE",请检查你的复制/粘贴 (4认同)
  • 无论我是否使用你的修复,当我调用服务sendmail重启时,我得到文件类:无法打开'ATURE(authinfo,':没有这样的文件或目录 (3认同)

fly*_*ain 14

结合上面的两个答案,我终于让它工作了.请注意,每个字符串的第一个单引号是 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
Run Code Online (Sandbox Code Playgroud)