/    Sign up×
Community /Pin to ProfileBookmark

Sending an email?

I had some code which used to work fine, but just recently it has stopped working. Basically, it’s sending the e-mail as plain text, rather than as HTML formatted. The formatting used to work fine, but people started telling me it wasn’t rendering as HTML, and when I check by sending myself an email, it also is just text now. Can anyone tell me what’s going on? Is my code correct? Could it be something that my web host has changed?

[code=php]

$email = stripslashes($email);
$username = stripslashes($username);
$password = stripslashes($password);

$emailfrom = “[email protected]”;

$headers = “MIME-Version: 1.0rnContent-type: text/html; charset=iso-8859-1rnFrom:”.$emailfrom.”rn”;

$mailmessage = “<html>Thank you for registering.<br><a href=’http://www.mysite.net/validate.php?unid=”.$unid.”‘>Please click here to activate your account.</a></html>”;

$subject=”Your registration”;
mail($email, $subject, $mailmessage, $headers);

header(“Location: registered.php?returnurl=”.$returnurl);

[/code]

I just can’t work out why it suddenly stopped working? If anyone can think of a reason, I would be grateful for the help. Thanks

Toby

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@sanderJan 15.2004 — The only errors I can spot are missing <body> tags and perhaps a missing doctype in your email, but I would hardly think that this would cause your script to start working.

Perhaps your servers email settings have changed in order to only let text/plain messages get send?
Copy linkTweet thisAlerts:
@tobyw_1969authorJan 15.2004 — Thanks Sander. I tried again last night and it started to work again. It just seems to work sometimes and not others? Is it possible that the variables that get passed in could somehow 'screw up' the HTML? I use stripslashes on any variables passed in via the URL, so I don't know what else to do to prevent strange strings appearing.

I am having so many problems with my PHP message board - sometimes if I post a message it comes up with a page not found, but I hit back and try again and it finds the page ok. I check all the hyperlinks / form submits and they are all fine, but 1/5 times it doesn't find the page. Could it be something to do with my host?
Copy linkTweet thisAlerts:
@sanderJan 15.2004 — It could be your host yes. Are you running it off some free hosting servive with PHP support? If so, I greatly suggest you take a paid hosting account. I have some very good experiences with iPowerWeb ( www.ipowerweb.com ).
Copy linkTweet thisAlerts:
@tobyw_1969authorJan 15.2004 — No - fully paid up with simply.com. I talked to the technician today and he thought problems with 404 could be due to apache screwing up the page request if there are too many users on. Still can't understand the HTML thing though. It's intermittent. Will keep an eye on it and see how it goes.
×

Success!

Help @tobyw_1969 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...