Search code examples
phpmailer

how to send email template html page?


Im using PHPMAILER 5.2.7 !

  $to=$row['email'];
  $at=$row['updated_at'];
  $subject = "Your Password has been changed";
  $body = "<body background='red' style='bgcolore:red;'><p>Hello < ".$u." > your password has been 
  changed at ".$at." ! </p>";
  $SITEEMAIL='support@test.tn';
  $mail = new Mail();
  $mail->setFrom($SITEEMAIL);
  $mail->addAddress($to);
  $mail->subject($subject);
  $mail->body($body);
  $mail->send();

how can i switch the $body content with a html page (template) ?? tried to directly past the code inside $body but i dosen't work !


Solution

  • I see several strange things in your $body text, try using more simple contents from this sample first. github.com/PHPMailer/PHPMailer#a-simple-example

    In any case, you should also call $mail->isHTML(true); before sending.