i'm using the PHP mail() function to send mails with attachment. Therefore the PHP source contents an boundary to define where the attachment begins and ends.
So the question is: are there any ruels for creating this MIME boundary (exampt that are only letters and numbres are allowed) i still know this SO question -> What rules apply to MIME boundary? Is it necessary to create an boundary form an HASH? Because the following also works:
$headers .= "Content-Type: multipart/related; boundary=\"abc\"";
[...]
$msg .="--abc\n";
[...]
$msg .= "--abc--\n\n";
Is there a reason, why a MIME boundary should be an unique value?
..i didn't found any information at the Internet.
Thank you!
Nothing says the boundary markers have to be hashes, but they MUST be unique. Think of what would happen if the actual email text you're inserting naturally contains the words --abc--
somewhere.
Your email would look something like this:
--abc-- <--actual boundary
This is my email. There are many like it, but this one is mine.
Now for some reason I'm going to put in a line that shouldn't be there
--abc-- <--part of the email
There it was. Did you see it? No, you didn't, because the mail client saw a boundary
line and sliced it out. Because of this extra boundary, now the email has 2 sections,
instead of 1.
--abc-- <--actual boundary
So... How is a mail client to know what's part of the email and what's just "overhead"? That's why you use unique boundaries.
Hashes are simply the easiest method. It's unlikely in the extreme that an email text would happen to contain its own hash value in the exact spot where it could be seen as a boundary marker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With