1. Apr 28, 2021 PHPMailer is a popular mail sending library for PHP. It supports mail sending via mail function or Simple Mail Transfer Protocol (SMTP). This library simplifies the complicated process of building a PHP mail by providing a set of functions to create and send an email.
  2. PHPMailer is a code library to send (transport) emails safely and easily via PHP code from a web server (MUA to the MSA server).

Feb 04, 2021 PHPMailer is a fully-featured email creation and transport class for PHP which allows you to send email via SMTP. Visit PHPMailer’s GitHub page for further details on what it has to offer. Installing PHPMailer on a Shared server View the following article for instructions on installing on a Shared server.

PHPMailer POP-Before-SMTP Authentication Class.

Specifically for PHPMailer to use for RFC1939 POP-before-SMTP authentication.1) This class does not support APOP authentication.2) Opening and closing lots of POP3 connections can be quite slow. If you needto send a batch of emails then just perform the authentication once at the start,and then loop through your mail sending script. Providing this process doesn'ttake longer than the verification period lasts on your POP3 server, you should be fine.3) This is really ancient technology; you should only need to use it to talk to very old systems.4) This POP3 class is deliberately lightweight and incomplete, implementing justenough to do authentication.If you want a more complete class there are other POP3 classes for PHP available.

Shutter count sony alpha a6000

Phpmailer attachment


Phpmailer bcc
No private methods found
No private properties found

PHPMailer is a PHP library that has an inbuilt function to send emails safely and easily using PHP from the server.

Mail is a useful functionality on the website.

It is used for user verification, forgot password, sending information, etc.

Github phpmailer

In this tutorial, I show how you send emails using server SMTP with PHPmailer in PHP.


1. PHPMailer

  • Using the composer to add PHPMailer to the project.
  • Navigate to your project directory and execute the following command –
  • It will install and create an autoload.php file in the vendor directory.

2. Get SMTP Details

  • Login to your server using cPanel.
  • Navigate to Email Accounts.
  • Create a new email from which you want to send Email if not exists. Click on the Set Up Mail Client.

NOTE – It may differ according to the server.

  • Scroll the page on the left side SMTP details are available.
  • Username, password, Outgoing host is been used for PHPMailer configuration. Using 587 port instead of 465.

3. PHP


Import PHPMailer, Exception class and include 'vendor/autoload.php'.

Create an object of PHPMailer.

Assign 0 to $mail->SMTPDebug to disable debugging. To enable pass 2.

Specify server host in $mail->Host, username in $mail->Username, and password in $mail->Password. Assign 'tls' in $mail->SMTPSecure and 587 to $mail->Port.

NOTE – All this value get from previous step.

Specify sender email-id and name in $mail->setFrom() and recipient email-id and name in $mail->addAddress().

Specify mail subject, and body in $mail->Subject, $mail->Body, and $mail->AltBody.

Attach file using $mail->addAttachment() method. You can specify the file name using the 2nd parameter.

Call $mail->send() to send a request.

Completed Code

4. Conclusion

Get the SMTP details from the cPanel if you don’t have and use it to configure PHPMailer. Enable the debugging by assigning 2 to $mail->SMTPDebug if getting an issue while sending the email.

If you found this tutorial helpful then don't forget to share.
Are you want to get implementation help, or modify or extend the functionality of this script? Submit paid service request.

Related posts:

Phpmailer Gmail Settings



  • 2