Linux配置mail.rc文件,发送邮件

  • Post author:
  • Post category:linux


增加下面几行,指定smtp服务器和发件发件账号

vim /etc/mail.rc

set from=testxxxx@xxxwm.com

set smtp=smtp.xxxwm.com

set smtp-auth=login

set smtp-auth-user=test_app

set smtp-auth-password=Xxxxxxx

启动postfix服务

#postfix start

发件测试:

[root@docker-41 data]# echo “hello, APP” | mail -s “HELLO , APP” qxxxxxg@xxxwm.com

[root@docker-41 data]# smtp-server: 535 5.7.8 Error: authentication failed: authentication failure

“/root/dead.letter” 11/316

. . . message not sent.

yum -y install cyrus-sasl-md5 cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel

[root@docker-41 data]# service saslauthd start

Redirecting to /bin/systemctl start saslauthd.service

再次测试:

[root@docker-41 data]# echo “hello, APP” | mail -v -s “HELLO , APP” qixxxx@xxxwm.com

Resolving host smtp.xxxwm.com . . . done.

Connecting to 139.xxx.xxx.63:smtp . . . connected.

220 Welcome to our mail.xxxwm.com SMTP

>>> EHLO docker-41

250-mail.xxxwm.com

250-PIPELINING

250-SIZE 100000000

250-ETRN

250-AUTH PLAIN LOGIN

250-AUTH=PLAIN LOGIN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

>>> AUTH LOGIN

334 VXNlcm5hbWU6

>>> dGVzdF9hcHA=

334 UGFzc3dvcmQ6

>>> Q203OEx5bjhBUFA=

535 5.7.8 Error: authentication failed: authentication failure

smtp-server: 535 5.7.8 Error: authentication failed: authentication failure

“/root/dead.letter” 11/316

. . . message not sent.

在别的机器测试:成功!

[qxxxx@VM_12_17_centos ~]$ echo “hello, APP” | mail -v -s “HELLO , APP” qxxxx@xxxwm.com

Resolving host smtp.puyiwm.com . . . done.

Connecting to 139.199.149.63:smtp . . . connected.

220 Welcome to our mail.xxxwm.com SMTP

>>> EHLO VM_12_17_centos

250-mail.xxxwm.com

250-PIPELINING

250-SIZE 100000000

250-ETRN

250-AUTH PLAIN LOGIN

250-AUTH=PLAIN LOGIN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

>>> AUTH LOGIN

334 VXNlcm5hbWU6

>>> bmFnaW9z

334 UGFzc3dvcmQ6

>>> Q203OEx5bjhRRw==

235 2.7.0 Authentication successful

>>> MAIL FROM:<nagxxxxx@xxxwm.com>

250 2.1.0 Ok

>>> RCPT TO:<qxxxxx@xxxwm.com>

250 2.1.5 Ok

>>> DATA

354 End data with <CR><LF>.<CR><LF>

>>> .

250 2.0.0 Ok: queued as 006F762FA

>>> QUIT

221 2.0.0 Bye

应该不是sasl的问题,换了别的账号就能发,新建的账号发不了

有空再研究,先用旧的账号吧

10.2.2.41



版权声明:本文为MRQ1734原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。