Exim4 配置外部 SMTP 服务器发邮件

Kevin 教程 1,762 次浏览 34条评论

大多服务器监控脚本自带有通知功能,需要系统配置好邮件服务才能使用。通过安装 Exim4 邮件传输代理程序,可以快速配置邮件发送环境。比较简单方法可以采用外部 SMTP 服务器来发邮件,这样不易被视为垃圾邮件,适合邮件不特别频繁的使用场景。

Exim4 可以在软件包管理器里获取,安装前先更新一遍软件列表。

apt-get update && apt-get install exim4

Ubuntu 系统可能还需额外安装 mailutils 组件。

apt-get install mailutils

安装后,运行dpkg-reconfigure exim4-config命令启动配置向导。设置流程如下表格。

选项问题 设置操作
General type of mail configuration: 选择mail sent by smarthost; received via SMTP or fetchmail模式
System mail name: 输入本机邮箱地址域名,这里填写localhost.localdomain
检查下/etc/hosts文件127.0.0.1设置内容,应设置为:
127.0.0.1 localhost.localdomain localhost
127.0.0.1 主机名
IP-addresses to listen on for incoming SMTP connections: 使用默认值127.0.0.1
Other destinations for which mail is accepted: 设置收件人域名列表,填写localhost.localdomain
Machines to relay mail for: 留空不设置
IP address or host name of the outgoing smarthost: 设置发送邮件的 SMTP 服务器地址及端口
例如smtp.qq.com::587(注意是两个冒号)
Hide local mail name in outgoing mail? 选择 No
Keep number of DNS-queries minimal (Dial-on-Demand)? 选择 No
Delivery method for local mail: 选择mbox format in /var/mail/
Split configuration into small files? 选择 Yes

编辑/etc/exim4/passwd.client文件添加邮箱信息,格式为:SMTP服务器 : 邮箱帐户 : 登录密码。为避免SMTP域名地址别名问题影响连接,可以配合通配符星号使用。

*.qq.com:username@qq.com:password

编辑/etc/email-addresses文件添加邮箱地址重写,使发出去的邮件显示指定邮箱地址。
下面以 root 用户帐户设置为例。

root: username@qq.com
root@localhost: username@qq.com
root@localhost.localdomain: username@qq.com
root@主机名: username@qq.com

完成上面设置后,重启服务刷新 Exim4 配置文件生效。

update-exim4.conf
invoke-rc.d exim4 restart
exim4 -qff

最后,测试邮件能否正常发送。如果遇到问题,检查tail /var/log/exim4/mainlog日志文件。

echo "This is a test mailing" | mail -s "Test mail" mail@example.com

评论列表

  1. #1

    Bardzo lubię tę stronę, dodana do zakładek. https://samocholand.pl/

  2. #2

    I wanted to post you that tiny remark to say thanks a lot over again just for the nice secrets you have featured in this case. It was really seriously open-handed with you to grant publicly just what many individuals might have offered for an ebook to generate some dough for themselves, mostly now that you might have tried it in case you desired. These secrets as well served to be a good way to fully grasp that other people online have the identical fervor much like my personal own to know the truth many more regarding this matter. I am sure there are numerous more pleasant sessions up front for people who scan your site. https://nfesusmmrn.online/

  3. #3

    I wanted to put you a very small word to help thank you very much yet again with the superb tips you have shown on this website. This is so unbelievably open-handed with you to provide without restraint what exactly numerous people would have supplied for an electronic book to make some profit on their own, principally since you might well have tried it in the event you wanted. Those thoughts likewise worked to provide a great way to understand that the rest have the same zeal the same as my very own to understand way more with regards to this issue. I’m sure there are many more fun occasions ahead for individuals that find out your blog post. https://gemerekliler.com/

  4. #4

    My wife and i were so relieved when Michael managed to finish up his studies via the precious recommendations he obtained using your web site. It is now and again perplexing to simply happen to be offering things which often some people might have been trying to sell. We remember we now have you to thank for this. The type of illustrations you made, the straightforward website navigation, the relationships your site make it easier to promote – it is mostly spectacular, and it is letting our son in addition to us recognize that this subject matter is pleasurable, which is certainly truly serious. Thanks for the whole thing! https://remeronmirtazapine.com

  5. #5

    I’m also commenting to let you be aware of of the cool discovery my child encountered checking your blog. She came to understand a lot of details, including how it is like to have a marvelous coaching heart to get folks easily fully grasp a variety of complicated issues. You actually did more than my desires. I appreciate you for delivering such good, dependable, edifying and also cool guidance on that topic to Ethel. https://paxilparoxetines.com/

  6. #6

    Thank you for each of your hard work on this web page. My aunt really likes going through investigations and it’s really obvious why. Most of us learn all of the lively method you offer practical strategies through this web site and even increase participation from some other people on the issue so our favorite girl is in fact learning a lot of things. Take advantage of the rest of the year. You are always doing a really good job. https://venlorz.com/#

  7. #7

    I enjoy you because of all of your effort on this blog. Debby enjoys conducting internet research and it’s easy to see why. A number of us hear all about the compelling manner you create efficient guides by means of the blog and boost contribution from other ones about this article and my child has been being taught a great deal. Enjoy the remaining portion of the new year. You’re carrying out a fantastic job. https://venlorz.com/#

  8. #8

    My spouse and i got really joyous that Jordan managed to do his reports through your precious recommendations he had through the web pages. It is now and again perplexing to just find yourself handing out secrets and techniques which people may have been selling. So we keep in mind we have got the writer to give thanks to for that. The most important illustrations you have made, the simple web site navigation, the relationships you will help to foster – it’s got many overwhelming, and it’s really leading our son in addition to the family know that the situation is exciting, which is rather mandatory. Thank you for everything! https://tofranilimipramine.com/#

  9. #9

    tadalafil gel: http://tadalafilonline20.com/ tadalafil pills 20mg

  10. #10

    india pharmacy drugs india pharmacy

  11. #11

    buying prescription drugs from canada generic pills for ed

  12. #12

    medications without a doctor’s prescription drugs without doctor script

  13. #13

    viagra from india cheap viagra online
    where to buy viagra

  14. #14

    viagra 100mg price buying viagra online
    viagra discount

  15. #15

    Ja naprawdę skarb twoją dzieło, Świetny post koronawirus test. https://testplytkowyn.pl/

  16. #16

    propecia no prescription finasteride cost

  17. #17

    order diflucan online uk generic diflucan

  18. #18

    viagra price https://viagrapills100.com/ when will viagra be generic

  19. #19

    when will viagra be generic https://viagrapills100.com/ viagra online usa

  20. #20

    when will viagra be generic https://viagrapills100.com/ best place to buy viagra online

  21. #21

    Bardzo interesujący temat, pozdrawiam za wystawienie się tlen medyczny inhalacyjny. https://tleninhalacyjnyn.pl/

  22. #22

    viagra 100mg price viagra cost
    buy real viagra online

  23. #23

    ed pharmacy ed pills online
    compare ed drugs

  24. #24

    real viagra without a doctor prescription usa ed treatment natural
    buy ed pills

  25. #25

    cheap ed pills from india cheap ed pills from india
    buy ed pills

  26. #26

    ed pills online drug prices
    cheap ed pills

  27. #27

    cheap ed pills order ed pills
    cheap ed pills from canada

  28. #28

    http://gabapentinst.com/# neurontin 300 mg caps

  29. #29

    https://zithromaxst.com/# where to get zithromax over the counter

  30. #30

    https://zithromaxst.com/# zithromax cost australia

  31. #31

    http://zithromaxproff.com/# zithromax without prescription
    can i buy zithromax online

  32. #32

    canadian pharmacy 1 internet online drugstore

  33. #33

    liberty auto insurance

  34. #34

    Sorry baby

    Casino.com

发表评论

电邮地址用于 Gravatar 头像显示,不会被公开可见。