0

Iam using PHP mailer to send an Email the message sent but email body is Empty

here is my code

foreach($results as $result)
{

    $email = $result['email'];

    $body = 'Hello'.$result['username'].' we remind you to return the book to library after' .$result['days'];

    $mail = new PHPMailer; 
    $mail->isSMTP();
    $mail->Host = 'mail.myhost.com;'; 
    $mail->SMTPAuth = true;
    $mail->Username = 'send@myhost.com';
    $mail->Password = 'mypassword';
    $mail->SMTPSecure = 'ssl';
    $mail->Port = 465;

    $mail->From = 'send@myhost.com'; 
    $mail->FromName ='Bookstore'; 
    $mail->addAddress($email, 'username');
    $mail->Subject = 'Book returned Time'; 
    $mail->Body = $body; 
    $mail->IsHTML(true);

    if(!$mail->send()) { 
        echo 'Message could not be sent.'; 
        //echo 'Mailer Error: ' . $mail->ErrorInfo; return $user ; 
    } else { 
        echo 'done'; 
    }

}
Chris
  • 4,762
  • 3
  • 44
  • 79
Muhammed
  • 584
  • 1
  • 11
  • 24

0 Answers0