Search code examples
phpmailermime

PHPMailer to send MIME message


I cannot seem to find any docs indicating that this is possible, is there a way to send a MIME formatted message using PHPMailer?

I'm not using $mail->setFrom, $mail->Subject, $mail->Body etc. because the content I have is already in mime format ie. a block of text similar to below

From: Some One <someone@example.com>
MIME-Version: 1.0
Content-Type: multipart/mixed;
        boundary="XXXXboundary text"
Subject: This is a test

This is a multipart message in MIME format.

--XXXXboundary text
Content-Type: text/plain

this is the body text

--XXXXboundary text
Content-Type: text/plain;
Content-Disposition: attachment;
        filename="test.txt"

this is the attachment text

--XXXXboundary text--

Solution

  • Out of the box, no. It might be possible if you wrote a new client class that made use of the low-level SMTP class, but this is really not PHPMailer's purpose and it won't do this in its current form. You might be better off using Symfony's or Laminas' email components.