Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to send Email with only attachment and no body? #3064

Open
ageir opened this issue Jun 14, 2024 · 1 comment
Open

Question: How to send Email with only attachment and no body? #3064

ageir opened this issue Jun 14, 2024 · 1 comment

Comments

@ageir
Copy link

ageir commented Jun 14, 2024

Problem description

I'm sending emails to an API/System.
The mail can not have multipart.
The mail should not contain a body.
Only a file attachment.

I tried allowing empty body, but it's creating multipart mail anyway.

How can I send an email with only one part that is an attachment?

I read the documentation but can not find how to do it.

@Synchro
Copy link
Member

Synchro commented Jun 14, 2024

PHPMailer doesn't support arbitrary MIME structures, only a few common ones. While this makes it easy to send common text+HTML+attachments messages, it also means you don't have control for more unusual structures. You could try setting the ContentType to your MIME type and assigning it to Body, like this:

$mail->ContentType = 'image/png';
$mail->Encoding = PHPMailer::ENCODING_BASE64;
$mail->Body = file_get_contents('my_img.png');

I'm not 100% sure that will work, but it's worth a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants