Dharm Shankar
Dharm Shankar

Reputation: 53

Send Mail with PHP

We are sending HTML mails to our clients but some clients getting HTML code instead of proper formatted output. We can't ask our client to changes settings etc.So, how can i send mail to deliver proper formatted output.

Upvotes: 0

Views: 151

Answers (3)

Martin Samson
Martin Samson

Reputation: 4090

I would highly recommend the http://swiftmailer.org/ library.

See http://masom.posterous.com/using-swiftmailer-in-lithium for an example on php 5.3+

Upvotes: 0

rocksfrow
rocksfrow

Reputation: 980

You need to send the emails in multipart format. This will enable the mail client to display a text version of your email if they do not support HTML. This will also require that you have both a text/html version of the email, or use a descent html2text converter.

I would recommend using the PHPMailer class to drastically simplify the process of sending the HTML emails with text content.

See, http://sourceforge.net/projects/phpmailer/

Upvotes: 0

Dennis
Dennis

Reputation: 14477

Sending the header Content-Type: text/html is sufficient for any client that can display HTML to treat your message as such. The problem is, not all clients understand HTML...

The safest bet is to always send a multipart message. It contains HTML for those clients that understand it and normal text for those that do not.

This tutorial covers the basic syntax.

Upvotes: 2

Related Questions