Posted on

by

in

How to send mail using PHP mail configuration

How to send mail using PHP mail configuration

Sending mail is an internal part of a business. Nowadays being quick and responsive is very important especially when it comes to giving an answer to the customer. Multiple times well-planned communication are deciding factors that users take into consideration while purchasing our product.

There are several ways to deliver mail while we are looking into PHP mail. At the very core, you can send an email via PHP by using a library such as PHPMailer with SMTP. PHPMailer is an effective method to send emails in PHP based environment.

1. Gathering details for PHPMailer:-

To use PHPMailer you need to create an email account. You can do this at Email Account section in cPanel (web hosting panel).

How to send mail using PHP mail configuration

 

 

 

 

2. Creating a test file for PHP mail:-

First of all, we need to create a file for PHP mail. We can place that file in the public_html directory. You can reach to this through a file manager. Let’s name the file mail.php.

How to send mail using PHP mail configuration

3. To understand how PHP file works:-

How to send mail using PHP mail configuration

 

 

 

 

 

 

Understand the importance of each component:-

PHPMailer

This line imports the class library of PHPMailer to a global namespace. While running mail.php file we should include PHPMailer library class file, Without class file, it is not possible to send mail.

$mail->

This variable contains vital information about server details, headers message and more. This variable also ensures to the sender about SMTP authentication.

SMTPAuth= True

When the value is false then it means script can send mail without issue, But if the value is true then it cannot connect to SMTP if you have any issue in your script.

SMTPSecure= tls

This indicates that mail is secure. We can also use SSL for it.

Port

Port number 587 is default mail submission port. When a client is sending mail it gets routed by a proper mail server that’s why we use this port.

4. Running the PHPMailer script:-

Execute the script by entering YourDomain.com/testphpmailer.php and you will see this kind of message.

Leave a Reply

Your email address will not be published. Required fields are marked *