diff --git a/sources/tech/20170223 Sending Email via PHP in CentOS 7 using Sendmail.md b/sources/tech/20170223 Sending Email via PHP in CentOS 7 using Sendmail.md deleted file mode 100644 index 491158cb23..0000000000 --- a/sources/tech/20170223 Sending Email via PHP in CentOS 7 using Sendmail.md +++ /dev/null @@ -1,79 +0,0 @@ -translating---geekpi - -Sending Email via PHP in CentOS 7 using Sendmail -============================================================ - - ![sendmail logo](http://fasterland.net/wp-content/uploads/2017/02/sendmail-logo-750x450.png) - -If you are running a **web server** or a **VPS**, you may encounter the need of sending emails using your **PHP** application. - -In the same way, if you are running a **WordPress** blog or you are using any kind of **CMS** and you would allow your visitors to send you emails using a Contact form (for example using the **[Contact Form 7][3]** plugin for **WordPress**) you may need to install a simple program into your web server called **[sendmail][4]**. - -> «Sendmail is a general purpose internetwork email routing facility that supports many kinds of mail-transfer and delivery methods, including the Simple Mail Transfer Protocol (SMTP) used for email transport over the Internet.» [via Wikipedia][5]. - -**Sendmail** can be simply installed using the package manager of your distribution. - -Here are the instructions for installing **Sendmail** on **CentOS 7**. - -### Installation - -In order to install **sendmail** on your **CentOS 7** server, run the following command: - -``` -# yum install sendmail -``` - -### Allowing your server to send emails - -If you are using **SELinux** on your **CentOS 7** server, you have to allow **sendmail** to send emails using the following command: - -``` -# setsebool -P httpd_can_sendmail=on -``` - -### Send a test email using PHP - -Enter the php interactive shell using this command: - -``` -php -a -``` - - -In the interactive shell, paste the following line of code: - -``` -mail ('user@receiver.com', "Test email", "Test email from the Internet", null, "-f user@sender.com"); -``` - -Don’t forget to replace **user@receiver.com** with the receiver email address and **user@sender.com** with the sender email address. - -### Viewing the sendmail log - -In order to monitor the mail log, you can use this command: - -``` -tail /var/log/maillog -``` - - -Once **sendmail** is installed on your web server you can allow your users to contact you via email using a contact form.  - - --------------------------------------------------------------------------------- - -via: http://fasterland.net/sending-email-via-php-centos-7-using-sendmail.html - -作者:[Francesco Mondello][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://fasterland.net/ -[1]:http://fasterland.net/author/faster3ck -[2]:http://fasterland.net/ -[3]:https://wordpress.org/plugins/contact-form-7/ -[4]:http://www.sendmail.com/sm/open_source/ -[5]:https://en.wikipedia.org/wiki/Sendmail -[6]:http://fasterland.net/category/server-admin diff --git a/translated/tech/20170223 Sending Email via PHP in CentOS 7 using Sendmail.md b/translated/tech/20170223 Sending Email via PHP in CentOS 7 using Sendmail.md new file mode 100644 index 0000000000..c3391b606f --- /dev/null +++ b/translated/tech/20170223 Sending Email via PHP in CentOS 7 using Sendmail.md @@ -0,0 +1,76 @@ +在 CentOS 7 中使用 Sendmail 通过 PHP 发送邮件 +============================================================ + + ![sendmail logo](http://fasterland.net/wp-content/uploads/2017/02/sendmail-logo-750x450.png) + +如果你运行了一个** web 服务器** 或者一台** VPS **,你可能需要在你的** PHP ** 程序中发送邮件。 + +同样,如果你正在运行一个** WordPress **博客,或者你正在使用任何类型的** CMS **,你允许你的访问者通过联系栏向你发送电子邮件(例如使用** WordPress **的 **[ Contact Form 7][3]**插件**),你可能需要安装一个名为 **[sendmail][4]** 的程序到你的 web 服务器上。 + +>«Sendmail 是一个通用的互联网电子邮件路由工具,支持多种邮件传输和传递方法,包括用于通过 Internet 进行电子邮件传输的简单邮件传输协议(SMTP)。»[来自 Wikipedia][5]。 + +** Sendmail **可以通过你的发行版的软件包管理器安装。 + +以下是在** CentOS 7 **上安装** Sendmail **的说明。 + +### 安装 + +要在 **CentOS 7** 中安装 **CentOS 7** ,运行下面的命令: + +``` +# yum install sendmail +``` + +### 允许服务器可以发送邮件 + +如果在 **CentOS 7** 中使用了 **SELinux**, 你需要使用下面的命令允许 **sendmail** 发送邮件: + +``` +# setsebool -P httpd_can_sendmail=on +``` + +### 使用 PHP 发送一封测试邮件 + +使用这个命令进入 php 交互 shell 中: + +``` +php -a +``` + + +在交互 shell 中,粘贴下面的代码: + +``` +mail ('user@receiver.com', "Test email", "Test email from the Internet", null, "-f user@sender.com"); +``` + +不要忘记将 **user@receiver.com** 和 **user@sender.com** 分别替换为收件地址和发件地址。 + +### 浏览 sendmail 日志 + +要监控邮件日志,你可以使用这个命令: + +``` +tail /var/log/maillog +``` + + +在服务器上安装 **sendmail** 完成后,你可以允许你的用户通过联系栏通过邮件联系你了。 + +-------------------------------------------------------------------------------- + +via: http://fasterland.net/sending-email-via-php-centos-7-using-sendmail.html + +作者:[Francesco Mondello][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://fasterland.net/ +[1]:http://fasterland.net/author/faster3ck +[2]:http://fasterland.net/ +[3]:https://wordpress.org/plugins/contact-form-7/ +[4]:http://www.sendmail.com/sm/open_source/ +[5]:https://en.wikipedia.org/wiki/Sendmail +[6]:http://fasterland.net/category/server-admin