PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have the section of code included below. It is a simple piece that I have gathered from a mail.mime group as to the sending of email in multiple formats. My goal here is simple. I need to send both a clear text formatted message and an HTML message in the same email. Including an image would also be useful but not required.
Any clear cut "functional" examples would be greatly appriciated. I have downloaded a few that just don't seem to work. The targets are Outlook (html format) and Horde/Imp (for the text format). I know, it sounds odd but these are the two clients that we need to make the format work on.
I was working on getting this to work for more than a day. I realized that there is no simple answer, In fact, i tried and retried and retried.
Outlook would display it one way, online email clients (Squirrelmail and such) would display it in another. Then at some point some would block it alltogether because the page is non-secure.
I never got it to work although i am curious as to how was anyone been able to get it to work.
NOTE: The code you got there is much better looking than mine (after millions of changes it looked like a monkey on steroids), however, Do NOT use multipart/mixed with HTML code that includes any images. Outlook will not load the image, and other browesers will quarantine your message.
Also, you need to add "--" before your boundaries.
So, since your code looks like: "---".md5(uniqid(time()))."";
your real boundaries should be like:
"-----".md5(uniqid(time())).""; Note the extra "--"
Let me know if you can get it to work reliably. I would like to fix mine myself.
mikusan wrote:Do NOT use multipart/mixed with HTML code that includes any images. Outlook will not load the image, and other browesers will quarantine your message.
A correctly built mime-based email can contain plain-text, HTML, images, and attachments... you just need to build the email headers and body correctly (which varies depending on the content of the email).
Normally a PHP class() for creating mime emails are huge, and the code posted above doesn't even scratch the surface of what's needed.
I have created my own mime-mail class() which works fine, if I have time I will dig it out and post it here but in the mean time I would suggest looking around for a pre-built mime email class() and use that.
Yeah, my warning of not using images in emails is due to the fact that i could not get it to work. So my suggestion was not to use images until you actually got the thing to work. Because that's one less variable to worry about.
Gen-ik wrote:
A correctly built mime-based email can contain plain-text, HTML, images, and attachments... you just need to build the email headers and body correctly (which varies depending on the content of the email).
About that, is text/html incorrect for the header tag. Apart the fact that i still can't get it to work, i got pretty close and found that when i just use normal headers and HTML based email, the email displays correctly, however, when i try to port my email content to the multipart email, the images do not load properly.
I am not sure why, maybe some extra security measures by email clients that do not want http:// links in some types of emails.
Using the code that I posted I can go to Imp and see the headers and they all look correct. I have tried varients for the boundary (that's just the one I ended with).
What is interesting is that in Outlook (and OWA) I get the whole thing as an attachment. This is the attachment contents.
Please note that I don't have a problem sending HTML or Text but rather the combination.