PHPMailer在本机移动客户端阅读器上显示已接收/已发送的电子邮件时,电子邮件显示不正确吗?

时间:2018-08-20 13:01:24

标签: php email phpmailer

我正在使用PHPMailer,在本地移动电子邮件上阅读时,电子邮件的输出存在一个小问题。当显示在桌面上时,电子邮件将按预期完美显示。但是,当我尝试通过本机电子邮件阅读器(例如iPhone或Android上预安装的“邮件”应用程序)阅读它们时,电子邮件会逐个字母显示,例如:

在本地移动应用上显示

  

2

     

0

     

/

     

0

     

8

     

/

     

2

     

0

     

1

     

8

在台式机或Gmail移动应用上显示:

  

20/08/2018

有人遇到过这个问题,因为我不知道为什么会这样,整个电子邮件都会这样做吗?但是奇怪的是,仅对于本机电子邮件应用程序,因为通过Gmail阅读时,它可以正常显示。

谢谢。

代码:

<?php
    //Get Date
    $_todaysDate = new DateTime();
    $todaysDate = $_todaysDate->format('d/m/Y');

    //Set Email Main Body
    $body1 = '<img style="margin-left:25%" src="images/DocHeader.png" width="50%">';
    $body2 = '<br>'.$todaysDate;
    $body3 = '<br><br>Dear Full Name,<br>';
    $body4 = '<br>Email Full Body:';
    $body5 = '<br><img style="margin-left:25%" src="images/DocFooter.png" width="50%">';

    //Set Email Main Body (Footer)
    $footer1 = '<strong>Email From</strong>';
    $footer2 = '<strong>My Footer</strong>';

    //String Together Body & Footer
    $body = $body1.'<p style="margin-left:30%;margin-right:25%;">'.$body2.$body3.$body4.$body5.'</p>'.$body19.'<h4>'.$footer1.'</h4><p>'.$footer2.'</p>';

    //Start Email
    $mail = new PHPMailer(true); 

    //$mail->SMTPDebug = 2;                               // Enable verbose debug output
    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = 'mail.example.com;';                    // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = 'username@example.com';             // SMTP username
    $mail->Password = 'password';                         // SMTP password
    $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;                                    // TCP port to connect to

    //Set Recipients
    $mail->setFrom('info@example.com', 'Info');
    $mail->addAddress('toEmail@example.com', 'To Name');     // Add a recipient
    $mail->addReplyTo('info@example.com', 'Info');
    $mail->AddBCC("log@example.com", "Email Logs");

    //Set Content
    $mail->isHTML(true);
    $mail->Subject = 'Email Subject';
    $mail->Body    = ($body);
    $mail->AltBody = '';

    if(!$mail->Send()) {
        $locationLogin = 'Location: FailedLocation.php';
        header($locationLogin);
    } 
    else {
        $locationLogin = 'Location: SuccessLocation.php';
        header($locationLogin);
    }

?>

0 个答案:

没有答案