未加星标

Email on Raspberry Pi

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二03 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

raspberry pi

5 October 2016

More than likely you're going to want your Raspberry Pi to send you e-mail for alerts and events. Raspbian comes with the exim4 mail transport agent (MTA) that you can use to send e-mail. Your ISP is probably blocking your ability to relay mail, but with a little work you can configure exim4 to relay through an external provider, such as Gmail. To begin, make sure that exim4 is installed with the command:

$ sudo apt-get install exim4 exim4-config

Once installed go ahead and start the exim4 configuration with the command:

$ sudo dpkg-reconfigure exim4-config

This will launch a semi-graphical interface, called curses, that will guide you through the configuration. You can use the tab key to navigate between options and the Enter key to select them.

On the first screen, Mail Server configuration, select 'mail sent by smarthost; no local mail.' as the option and click Ok. Next enter your Mail server configuration. You can use a made up name here, but it must be one that resolves in DNS or exim4 will fail. See documentation on dnsmasq to set up a local DNS server to resolve domain names. I used 'raspberrypi.madirish.net' for my domain name. Once you've filled in the name click 'Ok' to continue.

For the next screen enter the IP addresses you wish to relay mail for. Using the default of 127.0.0.1 (the reserved IP for localhost) is normally sufficient. Click Ok to continue.

Next enter domains that you wish to relay locally, meaning domains that the server should handle itself. Localhost or other local domains are fine. Enter whatever local domains you want and click 'Ok' to continue. The next screen asks what domain to append to usernames in From address lines for mail originating from the Raspberry Pi. It's a good idea to use the same name here as you did for the first mail configuration screen.

The next screen asks about the IP address or host name to use as a smart host. This is where you'll want to enter 'smtp.gmail.com::587' or another external provider. You enter the domain name of the mail relay, two colons, then the alternate port to use (the default port is 25, which is blocked by most ISP's).

Leave the list of recipient domains for which your server will relay mail blank and click 'Ok.' Similarly, unless you want to relay for other IP's on your LAN leave the IP ranges for unconditional mail relay blank and click 'Ok.'

Select 'No' when asked about keeping minimal DNS queries (Dial-on-Demand) and click 'Ok.' Finally select 'Yes' when asked about splitting configuration into smaller files. This will complete the configuration.

The only things left to do are to enter your credentials into a special file. To do this use vi, or another text editor, and edit the file /etc/exim4/passwd.client and add the line:

*.google.com:[email protected]:your_password

substituting in your gmail e-mail address and password so that you can authenticate. Once this is done you should restart exim with the command:

$ sudo systemctl restart exim4

And finally test your e-mail with the mail command, noting that entering a period on a single line ends the body of the mail. You can do so like this:

$ mail -s Test [email protected] Test . Cc:

If you have any problems check your mail logs with the commands:

$ sudo tail /var/log/exim4/mainlog

Having e-mail relay set up should allow you to do all sorts of additional projects on your Pi including setting up log monitoring, security tools, and other packages that rely on e-mail for alerting.

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: Raspberry Pi
分页:12
转载请注明
本文标题:Email on Raspberry Pi
本站链接:http://www.codesec.net/view/481190.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(41)