Mail send using smtp in php
Configure SMTP using my mail id and password but I am getting
“SMTP Error: Could not authenticate”
how to configure smtp server to send email in php | php send email smtp gmail | php smtp library | send mail in php using gmail smtp | php send email with mysql data | php mail not sending to gmail | php mailer smtp | php mail not sending to gmail php mail configuration | phpmailer without smtp
how to configure smtp server to send email in php | php send email smtp gmail | php smtp library | send mail in php using gmail smtp | php send email with mysql data | php mail not sending to gmail | php mailer smtp | php mail not sending to gmail php mail configuration | phpmailer without smtp
how to configure smtp server to send email in php | php send email smtp gmail | php smtp library | send mail in php using gmail smtp | php send email with mysql data | php mail not sending to gmail | php mailer smtp | php mail not sending to gmail php mail configuration | phpmailer without smtp
how to configure smtp server to send email in php | php send email smtp gmail | php smtp library | send mail in php using gmail smtp | php send email with mysql data | php mail not sending to gmail | php mailer smtp | php mail not sending to gmail php mail configuration | phpmailer without smtp
how to configure smtp server to send email in php | php send email smtp gmail | php smtp library | send mail in php using gmail smtp | php send email with mysql data | php mail not sending to gmail | php mailer smtp | php mail not sending to gmail php mail configuration | phpmailer without smtp
how to configure smtp server to send email in php | php send email smtp gmail | php smtp library | send mail in php using gmail smtp | php send email with mysql data | php mail not sending to gmail | php mailer smtp | php mail not sending to gmail php mail configuration | phpmailer without smtp how to configure smtp server to send email in php php send email smtp gmail php smtp library send mail in php using gmail smtp php send email with mysql data php mail not sending to gmail php mailer smtp php mail not sending to gmail php mail configuration phpmailer without smtp
Share
If you are using Gmail id you have to turn on the access for less secure apps. Otherwise, you’ll not get an email.
Please follow the below steps.
Please try using the below code
<?php
require 'class.smtp.php';
require 'class.phpmailer.php';
function smtpmailSend($to, $from, $from_name, $subject, $body) {
global $error;
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->SMTPAutoTLS = false;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = 'technologiesaviance@gmail.com';
$mail->Password = 'xxxxxxxxx'; // Your Gmail Password
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
}
if (smtpmailSend('bikash.hutait03@gmail.com', 'technologiesaviance@gmail.com', 'aviance', 'test mail', 'Hi! This is Bikash..')) {
//echo "Send!";
}
if (!empty($error)) echo $error;
?>
You will get ‘class.smtp.php’ & ‘class.phpmailer.php’ file from here
vote_up