Name: Prince
Birthday: 28 February 1993
Job: Freelancer
Email: [email protected]
Skype: 1081a1d198d8081c
A website is incomplete without mail functionality Both static and dynamic websites require it. As contact form or another way like feedback form or anyway, you can use it, So today I will tell you how you can send email from the website in an easy way.
With Few steps, you can, integrate this PHP code with your website and receive your website data or form it into your email helping Gmail SMTP. You need to change $mail->Username = '[email protected]';
mail id here and password $mail->Password = '#########';
here
Before Using this you need to change some settings in your Gmail account so that you can use Gmail SMTP – [How To Enable Less Secure App]
1. Turning on ‘less secure apps’ settings as mail domain Administrator
Security
> Basic settings
.Go to settings for less secure apps
.Enforce access to less secure apps for all users
radio button.Allow users to manage their access to less secure apps
, but don’t forget to turn on the less secure apps option in users’ settings then!)Save
button.2. Turning on ‘less secure apps’ settings as mailbox user
Security
.Turn on access
.Save
button.index.php
$mail = new PHPMailer(true);
Need to configure
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // your email id
$mail->Password = '#########'; // your password
$mail->SMTPSecure = 'tls';
$mail->Port = 587; //587 is used for Outgoing Mail (SMTP) Server.
$mail->setFrom('[email protected]', 'Prince Joal');
$mail->addAddress('[email protected]'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$bodyContent = '<h1>HeY!,</h1>';
$bodyContent .= '<p>This is a email that Prince joal send you From LocalHost using PHPMailer</p>';
$mail->Subject = 'Email from PrinceJoal Web';