Hi,
PHP provides a very simple mechanism for sending emails as compared to other scripting languages. But the problem with emails is, different email client work differently. What I mean to say is, there are many email clients which does not support HTML contents in email. What they do is, they just simply display the HTML tags, instead of parsing them. Now a good solution is to send the emails in plain format. Plain content type is supported by all email clients, irrespective of the fact that whether they support HTML or not.
But the problem with the format of Plain Content type emails, is you cannot create good looking email, with images and hyperlinks, as that will need a HTML content type. So the best solution is to format the email content is such a way that the email clients which support HTML email will show the emails in HTML format and the email client which does not support HTML will show the plain version of the HTML message.
For this you need to use multipart emails. It is very simple. You just need to create two version of the same email. One with the HTML tags and the other without the HTML tags. When you are done doing this, you need to keep few things in mind. Here is an example of multipart email:
<?php
$plain_message_text="This is a plain message:\n\nFor email clients, not supporting HTML\n\nhttp://php-drops.blogspot.com";
$html_message_text="This is a <b>HTML</b> message:<br/><br/>For email clients, supporting <i>HTML</i><br/><br/><a href='http://php-drops.blogspot.com' target='_blank'>PHP Drops</a>";
$notice = "This is a multi-part message in MIME format.";
$boundary = md5(time());
PHP provides a very simple mechanism for sending emails as compared to other scripting languages. But the problem with emails is, different email client work differently. What I mean to say is, there are many email clients which does not support HTML contents in email. What they do is, they just simply display the HTML tags, instead of parsing them. Now a good solution is to send the emails in plain format. Plain content type is supported by all email clients, irrespective of the fact that whether they support HTML or not.
But the problem with the format of Plain Content type emails, is you cannot create good looking email, with images and hyperlinks, as that will need a HTML content type. So the best solution is to format the email content is such a way that the email clients which support HTML email will show the emails in HTML format and the email client which does not support HTML will show the plain version of the HTML message.
For this you need to use multipart emails. It is very simple. You just need to create two version of the same email. One with the HTML tags and the other without the HTML tags. When you are done doing this, you need to keep few things in mind. Here is an example of multipart email:
<?php
$plain_message_text="This is a plain message:\n\nFor email clients, not supporting HTML\n\nhttp://php-drops.blogspot.com";
$html_message_text="This is a <b>HTML</b> message:<br/><br/>For email clients, supporting <i>HTML</i><br/><br/><a href='http://php-drops.blogspot.com' target='_blank'>PHP Drops</a>";
$notice = "This is a multi-part message in MIME format.";
$boundary = md5(time());