GmailAndExim4 ,Using Exim4 to send Messages through GMail


Using Exim4 to send Messages through GMail

Debian ships default with Exim4 as a mail server. To use this to send messages through Google’s smtp servers for GMail accounts, you need to do the following.

# dpkg-reconfigure exim4-config

-Choose YES, split configuration into small files

-Choose mail sent by SMARTHOST; received via SMTP or fetchmail

-Type System Mail Name: localhost

-Type IP Adresses to listen on for incoming SMTP connections: 127.0.0.1

-Leave Other destinations for which mail is accepted blank

-Leave Machines to relay mail for: blank

-Type Machine handling outgoing mail for this host (smarthost): smtp.gmail.com::587

-Choose NO, don’t hide local mail name in outgoing mail.

-Chose NO, don’t keep number of DNS-queries minimal (Dial-on-Demand).

Run

# vi /etc/exim4/passwd.client

and add the following lines:

gmail-smtp.l.google.com:yourAccountName@gmail.com:y0uRpaSsw0RD
*.google.com:yourAccountName@gmail.com:y0uRpaSsw0RD
smtp.gmail.com:yourAccountName@gmail.com:y0uRpaSsw0RD

The following only applies to exim 4.50 in sarge; in etch and sid the port can be configured via debconf with smtp.gmail.com::587. See the Debian exim docs for more detailed description.

The following will only work in split configuration.

Next, tell it what port to try. Run

# vi /etc/exim4/conf.d/transport/30_exim4-config_remote_smtp_smarthost

and add the following line after the line containing “hosts_try_auth…”

port=587

Add your outgoing email-address to the /etc/exim4/email-addresses

# echo 'YOUR-USER-NAME@LocalHost: yourAccountName@gmail.com' >> /etc/exim4/email-addresses

Finally, run

# update-exim4.conf

Good luck.

Possible Problems

If this doesn’t work, first enable POP for your GMail account, and then try:

# tail /var/log/exim4/mainlog.

If you see something like

2005-10-23 21:51:04 1ETuIW-0002iB-Qo ** yourAccountName@gmail.com R=smarthost T=remote_smtp_smarthost: SMTP error from remote mailer after MAIL FROM:<yourAccountName@gmail.com> SIZE=1555: host gmail-smtp.l.google.com [64.233.163.111]: 530 5.7.0 Authentication Required 23sm863650nzn

except there is something different than

gmail-smtp.l.google.com,

the host might be resolving to something else. In that case, replace the gmail-smtp.l.google.com in your /etc/exim4/passwd.client with whatever it says.

To try test these changes immediately—you might have failed enough times to have a very long delay between retries—run

# exim4 -M 1ETuIW-0002iB-Qo

but replacing that garbage ID tag from the first line of the error entry in the log file with the ID of the failed message that you want to resend.

exim4 4.62-2, the default version for ubuntu Edgy has authentication problems. Bug report [WWW] 403583 shows [WWW] required changes to the hosts_try_auth clause of /etc/exim4/conf.d/transport/30_exim4-config_remote_smtp_smarthost.

If you see something like

failed to open /etc/exim4/passwd.client for linear search: Permission denied (euid=102 egid=102)

exim is unable to read the password file.

The following will restore the default permissions.

# chown root:Debian-exim /etc/exim4/passwd.client
# chmod 640 /etc/exim4/passwd.client

If you see in mainlog message that states “Credentials Rejected”, type:

# vi /etc/exim4/passwd.client

See below: http://wiki.debian.org/GmailAndExim4

and replace every yourAccountName@gmail.com with yourAccountName (delete @gmail).

Share
Posted in 电子邮件. Tags: , , , , , , . »

SMTP协议速查

客户端

SMTP命令

命令说明

HELLO <domain> <CRLF>

识别发送方到接收SMTP的一个HELLO命令

MAIL FROM:<reverse-path><CRLF>

<reverse-path>为发送者地址。此命令告诉接收方一个新邮件发送的开始,并对所有的状态和缓冲区进行初始化。此命令开始一个邮件传输处理,最终完成将邮件数据传送到一个或多个邮箱中。

RCPT TO:<forward-path><CRLF>

<forward-path>标识各个邮件接收者的地址

DATA <CRLF>

接收SMTP将把其后的行为看作邮件数据去处理,以<CRLF>.<CRLF>标识数据的结尾。

REST <CRLF>

退出/复位当前的邮件传输

NOOP <CRLF>

要求接收SMTP仅做OK应答。(用于测试)

QUIT <CRLF>

要求接收SMTP返回一个OK应答并关闭传输。

VRFY <string> <CRLF>

验证指定的邮箱是否存在,由于安全因素,服务器多禁止此命令。

EXPN <string> <CRLF>

验证给定的邮箱列表是否存在,扩充邮箱列表,也常禁止使用。

HELP <CRLF>

查询服务器支持什么命令

服务端

应答码

说明

501

参数格式错误

502

命令不可实现

503

错误的命令序列

504

命令参数不可实现

211

系统状态或系统帮助响应

214

帮助信息

220

<domain>服务就绪

221

<domain>服务关闭

421

<domain>服务未就绪,关闭传输信道

250

要求的邮件操作完成

251

用户非本地,将转发向<forward-path>

450

要求的邮件操作未完成,邮箱不可用

550

要求的邮件操作未完成,邮箱不可用

451

放弃要求的操作;处理过程中出错

551

用户非本地,请尝试<forward-path>

452

系统存储不足,要求的操作未执行

552

过量的存储分配,要求的操作未执行

553

邮箱名不可用,要求的操作未执行

354

开始邮件输入,以”.”结束

554

操作失败

Share
Posted in 电子邮件. Tags: . »