Table of Contents
Any web application may need send email through it's script. In PHP, we use mail() function to send from web server .However sometimes it may cause delivery issue.
Means when we send email from php using just mail() function , sometimes recipient don't receive the mail .To overcome this issue we need SMTP to send email . SMTP is the most recommended way to send email .Using this email send from mail server rather than web server .
There a famous library available in PHP called 'PHPMailer library' .It allow to send email via SMTP having lots of configuration .
It allows to send plain text, HTML text .
We have created below tutorials on how to send HTML email with SMTP in PHP using PHPMailer library. you can use this script in your PHP website to send email.
Send HTML email
Send HTML Email with Attachments
Below demonstrate using addAttachment() function to send email with attachment. you can use multiple times the same function to send multiple attachment as shown below .
Send Email to Multiple Recipients
We can also send the same email to multiple recipients using addAddress() function as shown below .
Send Email using Gmail SMTP
We can also send email using our gmail SMTP details. to do so,first of all you need to change some setting in your gmail account . Follow below steps :- After logging in gmail, go to the My Account page. Click the Signing in to Google link from Sign-in & security section.
- Now on the same page, scroll down below ,find 'Password & sign-in method ' section and turn Off the ' 2-Step Verification'
- Again scroll down ,find 'Connected apps & sites' . Turn on there 'Allow less secure apps'
If you have any query on this tutorials, write below on comment section . I will try my best to reply comments .
We also provide advance PHP course with e-commerce project based training. visit our website www.unitedwebsoft.in/php-training-in-delhi-noida