2012-04-28 49 views
163

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

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

我已经这样做:

sudo apt-get install sendmail 

然后

sudo sendmailconfig 

,但我不知道是什么,最后一个实际上没有。

+3

@ThiefMaster是否我们不再将问题迁移到相应的SE网站? – Michael 2014-12-03 22:58:25

+0

这个问题太老了,无法迁移(当我关闭它时它已经是如此)。 – ThiefMaster 2014-12-03 23:01:59

+1

这些答案都不适合我。我发现这篇适合我的在线文章:http://www.daveperrett.com/articles/2013/03/19/setting-up-sendmail-with-sendgrid-on-ubuntu/ – 2016-07-22 18:42:55

回答

129

当您在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 [email protected] 

下面将让你的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):

m4 sendmail.mc > sendmail.cf 

重新启动sendmail守护程序:

service sendmail restart 
+2

当我试着最后一个命令时这 bash:我的测试电子邮件从sendmail发送:没有这样的文件或目录 – UXE 2012-04-28 00:48:39

+0

也应该在这些文件中编辑,以启用通过SMTP服务器凭证发送? – UXE 2012-04-28 00:52:25

+1

添加了添加smtp中继的说明。 – Venice 2012-04-28 01:18:55

35

我得到最多的回答工作(不能答复还)经过一次小小的编辑

这不适合我:

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

每个字符串的第一个单引号改为反引号(')是这样的:

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

的变化后,我跑:

sudo sendmailconfig 

而且我在业务:)

+3

是否使用您的修复程序,当我调用服务sendmail重新启动,我得到fileclass:无法打开'ATURE(authinfo,':没有这样的文件或目录 – 2013-08-29 19:01:17

+4

它的“FEATURE”而不是“ATURE”,检查您的复制/粘贴 – jyavenard 2013-09-23 00:48:59

+0

你必须将它粘贴到sendmail.cf中的不同位置(我把它放在邮件程序上方,但我仍然没有邮件) – Toskan 2016-04-29 00:03:36

12

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

我仍然有问题来理解行AuthInfo ...你可以举一个例子。 .. – 2014-02-20 15:47:47

+0

例如,我的客户端信息只有一行,'AuthInfo:smtp.gmail.com'U:username“”P:password“' – flyrain 2014-02-20 18:36:01

+0

仍然包含所有这些设置和AuthInfo我落入垃圾邮件列表 使用smtp.gmail.com与google.admin中的现有帐户 AuthInfo:smtp.gmail。com“U:root”“I:[email protected]”“P:password” 也试过 AuthInfo:smtp-relay.gmail.com“U:root”“I:[email protected]”“P:密码“ – 2016-03-23 15:25:25