...

View Full Version : How to correctly format an email in php



kevinkhan
02-22-2010, 11:07 AM
Hi set up a mail function like this


mail($email,"AdsInDublin - Upgrade Your Free Ad To A Premium Ad For Only €5",
"Upgrade Your Ad To Premium For Better Responses!<br /><br />
This email is regarding your Ad. <a href='http://www.adsindublin.com/freeads/{$id}'> {$title} </a> posted on AdsInDublin.com.<br /><br />
Are you getting the responses you hoped for? If not you have the option to upgrade your ad to a Premium Ad. There are a number
of advantages of upgrading your ad to a premium ad. First of all your ad will imediately get moved to the first ad on the first page of the website and will stay
there until another person upgrades there ad. Your ad will also be displayed on the right hand column of every page of the website ensuring maximum exposure. Your ad
will also stay on top of the listing in the category you have placed your ad in.<br /><br />
To convert your ad to Premium, login to AdsInDublin.com and go to this address http://www.adsindublin.com/classified/premium/id/{$id} <br /><br />
If you have any questions or need help creating a premium ad please email us on info@adsindublin.com.<br /><br />
Thanks<br /><br />
AdsInDublin.com<br />

", $headers);

and when i get an email it comes out exactly like the above.. How do i format it in such a way that it comes out like the following..

______________________________________________________

Upgrade Your Ad To Premium For Better Responses!

This email is regarding your Ad. <a href='http://www.adsindublin.com/freeads/{$id}'> {$title} </a> posted on AdsInDublin.com.

Are you getting the responses you hoped for? If not you have the option to upgrade your ad to a Premium Ad. There are a number of advantages of upgrading your ad to a premium ad. First of all your ad will immediately get moved to the first ad on the first page of the website and will stay there until another person upgrades there ad. Your ad will also be displayed on the right hand column of every page of the website ensuring maximum exposure. Your adwill also stay on top of the listing in the category you have placed your ad in.

To convert your ad to Premium, login to AdsInDublin.com and go to this address http://www.adsindublin.com/classified/premium/id/{$id}

If you have any questions or need help creating a premium ad please email us on info@adsindublin.com.

Thanks
AdsInDublin.com

greens85
02-22-2010, 11:23 AM
I'm PHP guru by any means, but I think you need to make the format of the email HTML, by doing something like so...


$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=sio-8859-1\r\n";
$headers .= "FROM: youremail@yourdomain.com";
mail($to, $subject, $emailbody, $headers);

Hope this is some help!

kevinkhan
02-22-2010, 11:25 AM
yes i have that.. but when i get an email..

The txt is all over the place and is not correctly formatted :(

greens85
02-22-2010, 11:30 AM
yes i have that.. but when i get an email..

The txt is all over the place and is not correctly formatted :(

Oh in that case, I'm not sure I can help any further...

I've just taken that code from a working example of mine, so I'm not really sure why it won't work for you :confused:

kevinkhan
02-22-2010, 11:34 AM
it works alright. I get an email.. its just when i get the email im getting <br /> tags displayed and not an actual break line

greens85
02-22-2010, 11:49 AM
it works alright. I get an email.. its just when i get the email im getting <br /> tags displayed and not an actual break line

I have line breaks in mine, but I have used <br/> rather than <br />, although to be honest I can't see that being the cause of the problem!

What email client are you viewing the email in, just out of interest?

kevinkhan
02-22-2010, 11:52 AM
thunderbird..

i have taken out the <br /> tags and put no html tage for the $body variable and just used the enter button to seperate lines and when i get email this is how it gets displayed..

Its weird.. hard to describe

kevinkhan
02-22-2010, 12:00 PM
I'm PHP guru by any means, but I think you need to make the format of the email HTML, by doing something like so...


$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=sio-8859-1\r\n";
$headers .= "FROM: youremail@yourdomain.com";
mail($to, $subject, $emailbody, $headers);

Hope this is some help!

Sorry you are right i forgot the $headers

the html tags works now :) :)

Do hotmail gmail etc support this by default?

greens85
02-22-2010, 12:08 PM
Sorry you are right i forgot the $headers

the html tags works now :) :)

Do hotmail gmail etc support this by default?

I have previously used a hotmail account to view emails generated in the same manner, and experienced no issues... so all should be well.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum