0

I am sending Emails with images, link and formatted text in $body. It's working fine until one of customer received broken email. I couldn't find solution. Please don't delete my question as i coundn't comment any post due to less reputation. Below is my code.

Do i have to add header in email, if yes and then can anyone tell me how to add header to following email?

    
$mail = new PHPMailer;
// use SMTP or use mail()
if (EMAIL_USE_SMTP) {
// Set mailer to use SMTP
    $mail->IsSMTP();
    $mail->Mailer = 'smtp';
    $mail->IsHTML(true);
    $mail->SingleTo = true;
    // Enable SMTP authentication
    $mail->SMTPAuth = EMAIL_SMTP_AUTH;
    // Enable encryption, usually SSL/TLS
        if (defined(EMAIL_SMTP_ENCRYPTION)) {
            mail->SMTPSecure = EMAIL_SMTP_ENCRYPTION;
          }
                        
        // Specify host server
        $mail->Host = EMAIL_SMTP_HOST;
        $mail->Username = EMAIL_SMTP_USERNAME;
        $mail->Password = EMAIL_SMTP_PASSWORD;
        $mail->Port = EMAIL_SMTP_PORT;
        } else {
            $mail->IsMail();
         }
                    
        //specify mail details
        $mail->From = CUSTOMER_LEAD_SUBMIT_FROM;
        $mail->FromName = CUSTOMER_LEAD_SUBMIT_FROM_NAME;
        $mail->AddAddress($customerEmail);
        $mail->Subject = $subject;
        $mail->Body = $body;
        if(!$mail->Send()) {
            $this->errors[] = MESSAGE_VERIFICATION_MAIL_NOT_SENT . $mail->ErrorInfo;
              return $this->errors;
            }
        else{
          return TRUE;
        }

Sneha Rao
  • 13
  • 3

1 Answers1

0

How is the email broken? I think it's encoding problem, so you have to add UTF-8. Like this for example

$mail->CharSet = 'UTF-8';

We must add this line just after the instantiation of the PHPMailer object

I think part of the problem has already been fixed here

Enjoy !