• Chào bạn, hãy đăng ký hoặc đăng nhập để tham gia cùng bọn mình và sử dụng được đầy đủ chức năng của diễn đàn :).
Ken

Hướng dẫn Send mail with php over Smtp Ubuntu

Ken

THÀNH VIÊN
Tham gia
05/07/2016
Bài viết
4,225
Learn how to install Ubuntu Server here.
Read the following tutorial on how to install apache2 on Ubuntu server.
Read this tutorial if you want to learn how to install PHP5.
Now you’ve installed and configured everything, it’s time to start the installation process.

First run the following command to install ‘ssmtp’. Ssmtp is a lightweight package, which uses the SMTP protocol to send emails out. SMTP is a widely used protocol, almost all email clients and providers support it. In this tutorial I’m using a Gmail account, you can use another email address or providers as well.

1sudo apt-get install ssmtp
Next, we’ll be editing a configuration file, which will point to the Gmail account. Run the following command:

1sudo nano /etc/ssmtp/ssmtp.conf
Add the following lines to the configuration file. Don’t forget to enter your own email address and password. And if you don’t use Gmail, enter the proper SMTP hostname as well.


1
2
3
4
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
AuthUser=[email protected]
AuthPass=yourpassword
Now it’s time to change the php.ini file that’s used with apache.


1sudo nano /etc/php5/apache2/php.ini
Find the “sendmail_path” line and set it like this:


1sendmail_path = /usr/sbin/sendmail -t
The -t option we’ve added basically tells ssmtp to read the “To”, “Cc” and “Bcc” headers and extract the recipients from there.

Close the php.ini file by pressing ctrl + x, Y and Enter.

Now it’s time to restart apache, and you can start sending out email with PHP!
 
Back
Top Bottom