Trở về đầu

foto1 foto2 foto3 foto4 foto5
Giảng viên
Nguyễn Tô Sơn - Thủ khoa Đại học Sư phạm Hà Nội
ĐT: 091.333.2869

HỌC TIN CÙNG THỦ KHOA

Thành công không phải đích đến, mà là cả một hành trình

Tìm kiếm

Xem tại: https://www.youtube.com/watch?v=IjA4CDGebYE

Trước tiên: Tạo mật khẩu ứng dụng mới của Gmail 

Cấu hình sendmail.ini như sau:

smtp_server=smtp.gmail.com

 

smtp_port=587

 

smtp_ssl=tls

 

error_logfile=error.log

 

debug_logfile=debug.log

 

auth_username=email_của_bạn

auth_password=password_của_bạn

 

Cấu hình php.ini như sau:

extension=php_openssl.dll

 

[mail function]

; For Win32 only.

; http://php.net/smtp

SMTP=stmp.gmail.com

; http://php.net/smtp-port

smtp_port=587

 

; For Win32 only.

; http://php.net/sendmail-from

sendmail_from = email_của_bạn

 

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").

; http://php.net/sendmail-path

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

 

File .php gửi thư bỏ qua việc cấu hình thư vì việc cấu hình đã được thực hiện ở file sendmail.ini và php.ini rồi.

 

$mail             = new PHPMailer();

/*

$mail->IsSMTP();             

$mail->CharSet  = "utf-8";

$mail->SMTPDebug  = 0;   // enables SMTP debug information (for testing)

$mail->SMTPAuth   = true;    // enable SMTP authentication

$mail->SMTPSecure = "ssl"; //"tls";   // sets the prefix to the servier

$mail->Host       = "smtp.gmail.com"; // hoặc: mail.hoctincungthukhoa.com   // sever gui mail.

$mail->Port       = 587;// 579; //465;         // cong gui mail de nguyen

$mail->IsHTML(true);

*/

 

// xong phan cau hinh bat dau phan gui mail

$mail->Username   = $mFrom;  // khai bao dia chi email

$mail->Password   = $mPass;              // khai bao mat khau

$mail->SetFrom($mFrom, $nFrom);

 

$mail->AddReplyTo('Email_của_bạn', 'Báo cáo Tổng hợp'); //khi nguoi dung phan hoi se duoc gui den email nay

$mail->Subject    = $title;// tieu de email

$mail->MsgHTML($body);// noi dung chinh cua mail se nam o day.

$mail->AddAddress($mTo);

$mail->AddAddress($i);

 

//thuc thi lenh gui mail 

$mail->Send();

Giảng viên Nguyễn Tô Sơn, Thủ khoa Đại học Sư phạm Hà Nội. Điện thoại: 091.333.2869