Phpmailer以纯文本格式发送附件

时间:2019-07-18 21:58:23

标签: php html phpmailer

当我使用phpmailer发送四个pdf附件时,一个以pdf格式发送,其中三个以纯文本格式发送。像这样仅在Macbook应用程序邮件上发送。在gamil上,所有4个附件的发送情况都很好。

enter image description here

在此处输入代码

 $mail = new PHPMailer(true);
    try {
        $mail->CharSet = 'UTF-8';

        //Server settings
        $mail->SMTPDebug = 0;                                       // Enable verbose debug output
        $mail->isSMTP();
        $mail->Host       = 'smtp.gmail.com';  // Specify main and backup SMTP servers
        $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
        $mail->Username   = '***************';                     // SMTP username
        $mail->Password   = '***************';                               // SMTP password
        $mail->SMTPSecure = 'ssl';                                  // Enable TLS encryption, `ssl` also accepted
        $mail->Port       = 465;                                    // TCP port to connect to

        //Recipients
        $mail->setFrom('ebytyebyty@gmail.com', 'ebyty dokumenty');


        // Add a recipient;
        $mail->addAddress('drakxy998@gmail.com');
        $mail->addAddress($email);


        // Attachments
        $mail->addAttachment('Objednávka'.$id_fakt.'.pdf', $name = 'Objednávka_'.$id_fakt.'.pdf',  $encoding = 'base64', $type = 'application/pdf');         // Add attachments
        $mail->addAttachment('Plnomocenstvo.pdf', $name = 'Plnomocenstvo.pdf',  $encoding = 'base64', $type = 'application/pdf');    // Optional name
        $mail->addAttachment('Súhlassospracúvanímosobnýchúdajov.pdf', $name = 'Súhlas_so_spracúvaním_osobných_údajov.pdf',  $encoding = 'base64', $type = 'application/pdf');
        $mail->addAttachment('Vyhlásenieomajetku.pdf', $name = 'Vyhlásenie_o_majetku.pdf',  $encoding = 'base64', $type = 'application/pdf');


        // Content
        $mail->isHTML(true);                                  // Set email format to HTML
        $mail->Subject = 'ebyty dokumenty';


        $mail->Body = 'text';

        $mail->AltBody = 'ebyty dokumenty';

        $mail->send();
        echo 'Message has been sent';

    } catch (Exception $e) {
        echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
    }`enter code here`

0 个答案:

没有答案