Tuesday, December 25, 2018

php - sending email using gmail server







Hi



I want to send email using gmail server for my php site. Can anyone help me with the code using phpmailer for accomplishing this?




require("phpmailer/class.phpmailer.php");

$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
IsSMTP(); // send via SMTP

$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "mail@domain.com"; // SMTP username
$mail->Password = "mailpass"; // SMTP password
$webmaster_email = "admin@frendzpark.com"; //Reply to this email ID

$email="sanksmr@gmail.com"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi, This is the HTML BODY "; //HTML Body

$mail->AltBody = "This is the body when user views in plain text format"; //Text Body

if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...