Sending Mail Through PHPMailer

2 replies
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";
}
#mail #phpmailer #sending
Avatar of Unregistered
  • Profile picture of the author Fredbou
    Did you try setting $mail->Port = 587;

    Also, try $mail->SMTPSecure = 'tls'; as 'ssl' is deprecated
    Signature

    {{ DiscussionBoard.errors[11192597].message }}
  • Profile picture of the author jamie3000
    Yep, it's normally an authentication problem. So either wrong ports, wrong encryption type SSL/tls, wrong username password
    {{ DiscussionBoard.errors[11196991].message }}
Avatar of Unregistered

Trending Topics