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.

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.

  • Mở dấu nhắc lệnh và đi đến thư mục của dự án mà bạn muốn sử dụng PHPMailer.
  • Chạy lệnh sau: ________ 0
  • Đợi cho việc cài đặt hoàn thành. Nó sẽ tải xuống tất cả các lớp cần thiết vào thư mục dự án của bạn.

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.
Import the PHPMailer classe into the global namespace.
Note: Make sure that these lines are at the top of the script not inside any function.

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ủ:

  • SmtPDebug: Được sử dụng để hiển thị các tin nhắn liên quan đến các vấn đề trong kết nối và gửi email. Nó có các giá trị sau: Used to display messages regarding problems in connectivity and sending emails. It has following values:
    • 0: Đó là giá trị mặc định. Tắt gỡ lỗi.
    • 1: Hiển thị tin nhắn đầu ra được gửi bởi máy khách.
    • 2: Như 1, cộng với các phản hồi hiển thị nhận được từ máy chủ.
    • 3: Như 2, cộng với thêm thông tin về kết nối ban đầu - mức này có thể giúp chẩn đoán các lỗi của StartTls.
    • 4: Như 3, cộng với hiển thị thông tin cấp thấp hơn.
  • ISSMTP (): Đặt người gửi thư để sử dụng SMTP. Set mailer to use SMTP.
  • ismail (): Đặt người gửi thư để sử dụng chức năng thư PHP. Set mailer to use PHP’s mail function.
  • Máy chủ: Chỉ định các máy chủ. Specifies the servers.
  • SMTPAUTH: Bật/tắt Xác thực SMTP. Enable/Disable SMTP Authentication.
  • Tên người dùng: Chỉ định tên người dùng. Specify the username.
  • Mật khẩu: Chỉ định mật khẩu. Specify the password.
  • SmtPSecure: Chỉ định kỹ thuật mã hóa. Các giá trị được chấp nhận ‘TLS, hoặc‘ SSL. Specify encryption technique. Accepted values ‘tls’ or ‘ssl’.
  • Cổng: Chỉ định cổng TCP sẽ được kết nối. Specify the TCP port which is to be connected.
$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.

  • ISHTML (): Nếu được truyền đúng, hãy đặt định dạng email thành HTML. If passed true, sets the email format to HTML.
  • Chủ đề: Đặt chủ đề của thư. Set the subject of the Mail.
  • Cơ thể: Đặt nội dung của thư. Set the contents of the Mail.
  • ALTBODY: Cơ thể thay thế trong trường hợp ứng dụng khách e-mail không hỗ trợ HTML. Alternate body in case the e-mail client doesn’t support HTML.
$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 to
0
$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
1

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 to
4
$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
5
$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
6

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 to
9
$mail->setFrom('', 'Name');           // Set sender of the mail
$mail->addAddress('');           // Add a recipient
$mail->addAddress('', 'Name');   // Name is optional
0
$mail->setFrom('', 'Name');           // Set sender of the mail
$mail->addAddress('');           // Add a recipient
$mail->addAddress('', 'Name');   // Name is optional
1

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 optional
4

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 optional
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 to
0
$mail->setFrom('', 'Name');           // Set sender of the mail
$mail->addAddress('');           // Add a recipient
$mail->addAddress('', 'Name');   // Name is optional
9
$mail->addAttachment('url', 'filename');    // Name is optional
0
$mail->addAttachment('url', 'filename');    // Name is optional
1

require 'vendor/autoload.php';
3
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
7
$mail->addAttachment('url', 'filename');    // Name is optional
4
$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
0
$mail->addAttachment('url', 'filename');    // Name is optional
6

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();
90
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
6

require 'vendor/autoload.php';
3
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
74

require 'vendor/autoload.php';
36 7
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
6

9

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
00
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
01
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
022.

require 'vendor/autoload.php';
36
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
06
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
6

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
08

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
09


PHPMailer được cài đặt ở đâu?

Tệp PHP, bạn có thể sử dụng để bao gồm các thư viện đã cài đặt, trong trường hợp này là PHPMailer. Tệp này được đặt trong thư mục của nhà cung cấp trên mạng theo mặc định, mặc dù bạn có thể định cấu hình trình soạn thảo để sử dụng một tên thư mục khác.under the “vendor” directory by default, although you can configure Composer to use a different directory name.

Làm cách nào để sử dụng phpmailer?

Mở dấu nhắc lệnh và chuyển đến thư mục của dự án mà bạn muốn sử dụng phpmailer ...
ishtml (): Nếu được thông qua đúng, hãy đặt định dạng email thành html ..
Chủ đề: Đặt chủ đề của thư ..
Body: Đặt nội dung của thư ..
Altbody: Cơ thể thay thế trong trường hợp máy khách e-mail không hỗ trợ HTML ..

Làm cách nào để kích hoạt phpmailer?

Về bài viết này..
Tải xuống và cài đặt Trình soạn thảo từ https://getcomposer.org/doad/ ..
Nhấp vào tệp đã tải xuống để bắt đầu quá trình cài đặt ..
Tạo một thư mục nhà soạn nhạc mới ..
Lời nhắc lệnh tìm kiếm và mở ..
Điều hướng đến thư mục bạn muốn cài đặt phpmailer ..
Trình soạn thảo loại yêu cầu phpmailer/phpmailer ..

Làm thế nào để tôi biết nếu phpmailer được cài đặt?

Nếu bạn đã cài đặt nó theo cách thủ công, chỉ cần tải xuống phiên bản mới nhất từ GitHub và thay thế phiên bản hiện tại của bạn.Ok, vì vậy chỉ cần tìm kiếm một trong các tệp của nó từ shell: find / -name class.phpmailer.php hoặc sử dụng định vị nếu bạn đã cài đặt đó.search for one of its files from a shell: find / -name class. phpmailer. php , or use locate if you have that installed.