Hướng dẫn where do i put phpmailer? - tôi đặt phpmailer ở đâu?
PHPMailer là một thư viện mã và được sử dụng để gửi email một cách an toàn và dễ dàng thông qua mã PHP từ máy chủ web. Gửi email trực tiếp qua mã PHP đòi hỏi sự quen thuộc cấp cao đối với giao thức tiêu chuẩn SMTP và các vấn đề và lỗ hổng liên quan về tiêm email để gửi thư rác. PHPMailer đơn giản hóa quá trình gửi email và nó rất dễ sử dụng. Show Cài đặt: Cách tốt nhất để cài đặt PHPMailer là sử dụng trình soạn thảo. Trước khi tiếp tục, hãy đảm bảo cài đặt trình soạn thảo. The best way to install PHPMailer is by using composer. Before proceeding make sure to install composer.
Sử dụng PHPMailer: Nhập phpmailer lượn vào không gian tên toàn cầu. Không đảm bảo rằng các dòng này nằm ở đầu tập lệnh không nằm trong bất kỳ chức năng nào. use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; Tải trình tải tự động của nhà soạn nhạc. require 'vendor/autoload.php'; Tạo một đối tượng lớp PHPMailer. $mail = PHPMailer() Định cấu hình cài đặt máy chủ:
$mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gfg.com;'; // Specify main SMTP server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, 'ssl' also accepted $mail->Port = 587; // TCP port to connect to Thêm những người nhận thư. $mail->setFrom('', 'Name'); // Set sender of the mail $mail->addAddress(''); // Add a recipient $mail->addAddress('', 'Name'); // Name is optional Thêm tệp đính kèm (nếu có). $mail->addAttachment('url', 'filename'); // Name is optional Thêm nội dung.
$mail->isHTML(true); $mail->Subject = 'Subject'; $mail->Body = 'HTML message body in bold!'; $mail->AltBody = 'Body in plain text for non-HTML mail clients'; Cuối cùng, gửi email. $mail->send(); Và e-mail của bạn sẽ được gửi. Chương trình: Hoàn thành chương trình PHP để gửi e-mail bằng PHPMailer. Complete PHP program to send e-mail using PHPMailer. use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;0 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;1 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;0 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;4 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;5 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;6 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;8 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;9 require 'vendor/autoload.php';0 require 'vendor/autoload.php';1 require 'vendor/autoload.php';2 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 require 'vendor/autoload.php';5 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 require 'vendor/autoload.php';8 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail = PHPMailer()1 $mail = PHPMailer()2 $mail = PHPMailer()3 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail = PHPMailer()6 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail = PHPMailer()9 $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gfg.com;'; // Specify main SMTP server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, 'ssl' also accepted $mail->Port = 587; // TCP port to connect to0 $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gfg.com;'; // Specify main SMTP server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, 'ssl' also accepted $mail->Port = 587; // TCP port to connect to1 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gfg.com;'; // Specify main SMTP server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, 'ssl' also accepted $mail->Port = 587; // TCP port to connect to4 $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gfg.com;'; // Specify main SMTP server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, 'ssl' also accepted $mail->Port = 587; // TCP port to connect to5 $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gfg.com;'; // Specify main SMTP server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, 'ssl' also accepted $mail->Port = 587; // TCP port to connect to6 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gfg.com;'; // Specify main SMTP server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, 'ssl' also accepted $mail->Port = 587; // TCP port to connect to9 $mail->setFrom('', 'Name'); // Set sender of the mail $mail->addAddress(''); // Add a recipient $mail->addAddress('', 'Name'); // Name is optional0 $mail->setFrom('', 'Name'); // Set sender of the mail $mail->addAddress(''); // Add a recipient $mail->addAddress('', 'Name'); // Name is optional1 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail->setFrom('', 'Name'); // Set sender of the mail $mail->addAddress(''); // Add a recipient $mail->addAddress('', 'Name'); // Name is optional4 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail->setFrom('', 'Name'); // Set sender of the mail $mail->addAddress(''); // Add a recipient $mail->addAddress('', 'Name'); // Name is optional7 $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gfg.com;'; // Specify main SMTP server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, 'ssl' also accepted $mail->Port = 587; // TCP port to connect to0 $mail->setFrom('', 'Name'); // Set sender of the mail $mail->addAddress(''); // Add a recipient $mail->addAddress('', 'Name'); // Name is optional9 $mail->addAttachment('url', 'filename'); // Name is optional0 $mail->addAttachment('url', 'filename'); // Name is optional1 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail->addAttachment('url', 'filename'); // Name is optional4 $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gfg.com;'; // Specify main SMTP server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, 'ssl' also accepted $mail->Port = 587; // TCP port to connect to0 $mail->addAttachment('url', 'filename'); // Name is optional6 Các require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail->isHTML(true); $mail->Subject = 'Subject'; $mail->Body = 'HTML message body in bold!'; $mail->AltBody = 'Body in plain text for non-HTML mail clients';6 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail->isHTML(true); $mail->Subject = 'Subject'; $mail->Body = 'HTML message body in bold!'; $mail->AltBody = 'Body in plain text for non-HTML mail clients';9 $mail->send();0 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;6 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail->send();4 $mail->send();5 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;6 require 'vendor/autoload.php';3 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;7 $mail->send();9 0 |