Sending Mail Through PHPMailer

by 1 replies
3
I'm using PHPMailer with below code to send mail in PHP. But I'm not getting either sending mail or sending failed message, but the white screen. Please help me for the same.

$account="email_address@gmail.com";
$password="accountpassword";
$to="mail@subinsb.com";
$from="vishal@vishal.com";
$from_name="Vishal G.V";
$msg="<strong>This is a bold text.</strong>"; // HTML message
$subject="HTML message";


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


$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth= true;
$mail->Port = 465; // Or 587
$mail->Username= $account;
$mail->Password= $password;
$mail->SMTPSecure = 'ssl';
$mail->From = $from;
$mail->FromName= $from_name;
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $msg;
$mail->addAddress($to);



if(!$mail->send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}else{
echo "E-Mail has been sent";
}
#programming #mail #phpmailer #sending
  • Have you checked the error logs on your server? I suspect the issue might be your include(). Have you checked to make sure "phpmailer/class.phpmailer.php" is pointing at the correct location *relative* to the file where this code appears?

Next Topics on Trending Feed

  • 3

    I'm using PHPMailer with below code to send mail in PHP. But I'm not getting either sending mail or sending failed message, but the white screen. Please help me for the same. $account="email_address@gmail.com";