Birthday: 28 February 1993
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@example.com'; 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
Go to settings for less secure apps.
Enforce access to less secure apps for all usersradio 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!)
2. Turning on ‘less secure apps’ settings as mailbox user
Turn on access.
$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 = 'firstname.lastname@example.org'; // your email id $mail->Password = '#########'; // your password $mail->SMTPSecure = 'tls'; $mail->Port = 587; //587 is used for Outgoing Mail (SMTP) Server. $mail->setFrom('email@example.com', 'Prince Joal'); $mail->addAddress('firstname.lastname@example.org'); // 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';