Send mail in different colours using mail function

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!

Moderator: General Moderators

Post Reply
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Send mail in different colours using mail function

Post by me666 »

Hi i have set up my site so that it emails you a link and your info when you register and all works fine, the only thing is, i am looking to change the font colour in the email.
I have tried using the normal html font colour codes but that just displays as a code in the email rather than changing the colours.
Can any1 help me with thsi please?
Thanks :D
mickeyunderscore
Forum Contributor
Posts: 129
Joined: Sat Jan 31, 2009 9:00 am
Location: UK

Re: Send mail in different colours using mail function

Post by mickeyunderscore »

You need to send appropriate headers so the e-mail client knows that it is HTML and not plain text.

Couldn't remember what to put, so I looked this up from http://uk2.php.net/manual/en/function.mail.php:

Code: Select all

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
User avatar
Skoalbasher
Forum Contributor
Posts: 147
Joined: Thu Feb 07, 2008 8:09 pm

Re: Send mail in different colours using mail function

Post by Skoalbasher »

mickeyunderscore wrote:You need to send appropriate headers so the e-mail client knows that it is HTML and not plain text.

Couldn't remember what to put, so I looked this up from http://uk2.php.net/manual/en/function.mail.php:

Code: Select all

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
I've beenwondering about this as well. That's awesome! Now how to send an HTML file that's already created and put that in the $message section.
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Re: Send mail in different colours using mail function

Post by me666 »

excelent thanks, i tried sending mail via html before so i could use the </br> syntax to new line but wouldnt work, thanks for the response.
And the last question, i expect if your using php it would be something like using the include comand or the '$text = file_location/file_name'
not sure but just a guess
User avatar
Skoalbasher
Forum Contributor
Posts: 147
Joined: Thu Feb 07, 2008 8:09 pm

Re: Send mail in different colours using mail function

Post by Skoalbasher »

me666 wrote:excelent thanks, i tried sending mail via html before so i could use the </br> syntax to new line but wouldnt work, thanks for the response.
And the last question, i expect if your using php it would be something like using the include comand or the '$text = file_location/file_name'
not sure but just a guess
Yeah, I'm gonna look around for it. Nothing pressing yet. You know if you just want a new line, you could seperate with a "\n" that works in emails.
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Re: Send mail in different colours using mail function

Post by me666 »

yea found that on the net too.... only thing is if i use that in my php created email it dosent send and i get a delivery failer after 5 attempts of sending it, not sure why as this is the only solution i found on the net
thanks anyways
mickeyunderscore
Forum Contributor
Posts: 129
Joined: Sat Jan 31, 2009 9:00 am
Location: UK

Re: Send mail in different colours using mail function

Post by mickeyunderscore »

Does the mail() function fail? Or is it just undelivered?
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Re: Send mail in different colours using mail function

Post by me666 »

just undelivered, i get an email in my inbox of the senders email address saying it tried 5 times but failed
Post Reply