• Resolved mdreyfus

    (@mdreyfus)


    Email Logging dont work if i send mail with wp_mail and mutlipart content. Any suggestion for this case ?

    //code sample

    
    foreach ($attachments as $attachment) {
        $file_content = file_get_contents($attachment);
        $file_encoded = base64_encode($file_content);
    
        $body .= '--' . $boundary . "\r\n";
        $body .= 'Content-Type: application/pdf; name="' . basename($attachment) . '"' . "\r\n";
        $body .= 'Content-Transfer-Encoding: base64' . "\r\n";
        $body .= 'Content-Disposition: attachment; filename="' . basename($attachment) . '"' . "\r\n\r\n";
        $body .= chunk_split($file_encoded) . "\r\n\r\n";
    }
    
    $body .= '--' . $boundary . '--';
    
    wp_mail($to, $subject, $body, $headers, $file_paths);
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Michael

    (@donmhico)

    Hello,

    Thanks for creating this thread. Can you provide the whole code snippet? It might be possible that the issue is with the other parts of the snippet. For example, with the snippet you provided, we cannot determine the value of $headers and $file_paths .

    It can help if you can provide the whole code.

    Thank you!

    Thread Starter mdreyfus

    (@mdreyfus)

    Thanks for your reply.

    $file_path is an array of complete urls.

    Here is a more complete snippet

    $subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
    
    $attachments = array();
    
    foreach ($file_paths as $file_path) {
        $attachments[] = $file_path;
    }
    
    // Générer un délimiteur
    $boundary = md5(time());
    
    // En-têtes de l'e-mail
    $headers[] = 'MIME-Version: 1.0';
    $headers[] = 'Content-Type: multipart/mixed; boundary="' . $boundary . '"';
    
    $body = '--' . $boundary . "\r\n";
    $body .= 'Content-Type: text/html; charset=UTF-8' . "\r\n";
    //$body .= 'Content-Transfer-Encoding: 7bit' . "\r\n\r\n";
    $body .= $message . "\r\n\r\n";
    
    
    foreach ($attachments as $attachment) {
        $file_content = file_get_contents($attachment);
        $file_encoded = base64_encode($file_content);
    
        $body .= '--' . $boundary . "\r\n";
        $body .= 'Content-Type: application/pdf; name="' . basename($attachment) . '"' . "\r\n";
        $body .= 'Content-Transfer-Encoding: base64' . "\r\n";
        $body .= 'Content-Disposition: attachment; filename="' . basename($attachment) . '"' . "\r\n\r\n";
        $body .= chunk_split($file_encoded) . "\r\n\r\n";
    }
    
    $body .= '--' . $boundary . '--';
    
    return wp_mail($to, $subject, $body, $headers);
    Plugin Author Michael

    (@donmhico)

    Hello,

    Thank you for your response. I was able to log it, but I am not sure if this is really how you want the email to be sent. https://a.supportally.com/i/SCWkAF

    Have you tried turning off our plugin and sending it? Does it send? How does it look like?

    Thread Starter mdreyfus

    (@mdreyfus)

    Email and attachment files are sending, but don’t appear in Email Logging…

    Plugin Author Michael

    (@donmhico)

    Are you using the latest version of our plugin? Also can you provide the initial $subject?

    Thread Starter mdreyfus

    (@mdreyfus)

    Version 1.12.0
    The initial subject : Sample – Appel à cotisation 2024

    Plugin Author Michael

    (@donmhico)

    Hello,

    Thank you for giving us more details. We are unable to replicate your issue. Did you upgrade WP Mail Logging from an older version to 1.12.0? If yes, did you follow the instructions here?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Logging stop working with MultiPart email’ is closed to new replies.