Send Email via SMTP Server in PHP using PHPMailer

Remove term: php mail smtp authentication php mail smtp authentication

In this article you will get the knowledge about Send Email via SMTP Server in PHP using PHPMailer. Send email from PHP Script is the most popular feature for the web application. Basically mail() is used to send email in php. When you try to send email using the php mail() function, the mail is sent from your web server. Sometimes it may create issue on sending an email and fails to deliver mail to recipient email id. But with the help of SMTP you can overcome this issue, SMTP is the most recommended way to send email from the php script. When you try to send an email vis SMTP, email is send from the mail server rather than the web server.

PHPMailer library provides the easiest way to send email in php with SMTP.  PHPMailer library have various configuration options that allow you to send a text email, HTML mail and attachment.

Now, you will see how you can send HTML email with SMTP using PHPMailer in PHP. You can use the following code to send SMTP mail using PHPMailer library.

index.php

Use isHTML(true) to set email format to HTML

Send Email with Attachments:

Use addAttachment() method of PHPMailer class to add an attachment or multiple attachments  to the email.

Send HTML Email to Multiple Recipients:

Add addAddress() method multiple times for sending same email to the multiple recipients.

NOTE: Are you want to get implementation help, or modify or extend the functionality of this script? please leave your comment in below comment section.

Related posts