Share - Gửi Mail Bằng Thư Viện PHPMailer | Gextend - Forums
Có thể bạn quan tâm
- Home
- Forums New posts Search forums
- Resources Latest reviews Search resources
- Members Current visitors New profile posts Search profile posts
- What's new Featured content New posts New resources New profile posts Latest activity
Search
Everywhere Threads This forum This thread Search titles only Note Search Advanced search…- New posts
- Search forums
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
- Home
- Forums
- Discussion
- Web
- PHP
- Thread starter Thread starter filiallion
- Start date Start date 03/01/2018
- Tags Tags mail oauth php phpmailer pop3 smtp
filiallion
Administrator
Staff member Administrator Messages 590 Points 10 Language Tiếng Việt Đối với các bạn viết các ứng dụng web có gửi mail thì PHPMailer là một thư viện được chọn lựa. Mặc dù trong PHP đã có sẵn hàm gửi mail rồi nhưng thường thì hàm mail này bị chặn hoặc mail các bạn gửi có thể nằm trong mục spam. Việc sử dụng thư viện PHPMailer cũng khá đơn giản, các bạn theo dõi phần hướng dẫn sau đây để có thể sử dụng thư viện PHPMailer hiệu quả. Trước tiên, các bạn tải thư viện PHPMailer tại địa chỉ https://github.com/PHPMailer/PHPMailer. Trong gói thư viện này có 5 tập tin trong thư mục src, đây là toàn bộ thư viện PHPMailer mà các bạn cần sử dụng. Các bạn có thể sao chép 5 tập tin này vào ứng dụng web của các bạn. Tại vị trí các bạn muốn gửi mail, các bạn khai báo khối lệnh sau: PHP: //Require các thư viện PHPMailer require 'path/to/PHPMailer/Exception.php'; require 'path/to/PHPMailer/PHPMailer.php'; require 'path/to/PHPMailer/SMTP.php'; //Khai báo sử dụng namespace (Lưu ý tới vị trí khai báo này) use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; //Khởi tạo đối tượng PHPMailer $PHPMailer = new PHPMailer(true); //Khai báo cấu hình và gửi mail try { $PHPMailer->SMTPDebug = 2; $PHPMailer->isSMTP(); $PHPMailer->Host = 'smtp.example.com'; $PHPMailer->SMTPAuth = true; $PHPMailer->Username = '[email protected]'; $PHPMailer->Password = 'secret'; $PHPMailer->SMTPSecure = 'tls'; $PHPMailer->Port = 587; $PHPMailer->setFrom('[email protected]', 'From'); $PHPMailer->addAddress('[email protected]', 'Recipient'); $PHPMailer->isHTML(true); $PHPMailer->Subject = 'Here is the subject'; $PHPMailer->Body = 'This is the HTML message body'; $PHPMailer->send(); } catch (Exception $exception) { echo $PHPMailer->ErrorInfo; } Các bạn lưu ý thay đổi đường dẫn tới các tập tin thư viện cho chính xác cũng như các thông tin về máy chủ gửi mail, tài khoản, mật khẩu, cổng SMTP... Để CC hoặc BCC tới tài khoản khác, các bạn khai báo như sau: PHP: $PHPMailer->addCC('[email protected]'); $PHPMailer->addBCC('[email protected]'); Để đính kèm tập tin, các bạn khai báo như sau: PHP: $PHPMailer->addAttachment('path/to/file.zip'); Các bạn có thể tìm hiểu thêm về thư viện PHPMailer tại địa chỉ https://github.com/PHPMailer/PHPMailer/blob/master/README.md. You must log in or register to reply here. Share: Facebook X Bluesky LinkedIn Reddit Pinterest Tumblr WhatsApp Email Share Link- Home
- Forums
- Discussion
- Web
- PHP
Từ khóa » Gửi Mail Bằng Thư Viện Phpmailer
-
Gửi Mail Với Phpmailer - Thầy Long Web
-
Hướng Dẫn Gửi Mail Trong PHP Với PHPMailer - Freetuts
-
PhpMailer: Cách Sử Dụng Hàm Gửi Email đến Người Dùng Trong Php
-
Làm Thế Nào để Gửi Email Bằng PHP - Hostinger
-
PHP Gửi Email Với Thư Viện PHPMailer - YouTube
-
Hướng Dẫn Gửi Mail Trong PHP Với PHPMailer
-
Hướng Dẫn Hàm Gửi Mail PHP Từ A đến Z | Ironhack Việt Nam
-
Gửi Email Trong PHP
-
Hướng Dẫn Gửi Mail Trong PHP Với PHPMailer - TungChi'N
-
NEW Hướng Dẫn Gửi Mail Trong Php Với Phpmailer - Duy Pets
-
Hướng Dẫn Gửi Mail Trong PHP Với PHPMailer
-
Hướng Dẫn Gửi Mail Trong Php Với Phpmailer
-
PHPMailer Là Gì ? Hướng Dẫn Sử Dụng PHPMailer - Kho Tên Miền
-
Hướng Dẫn Cài đặt PHPMailer: Tính Năng Gửi Mail Tự động