yuckysocks Posted April 22, 2008 Share Posted April 22, 2008 Hi, I'm looking to get this function to work: mail('them@gmail.com', 'A new case study has been posted!', 'Go to <a href="admin.php">the admin page</a> to look it over. It is information regarding $schoolname', 'From: me@gmail.com'); The mail gets sent properly, but the link and the variable aren't treated properly. The message is in fact going to gmail, so maybe it has something to do with how they treat html in messages, but at least the variable ought to get filled in, eh? It's a POSTed variable, do I need to call it that? Anyhow, thanks for your always prompt help. Alex Quote Link to comment Share on other sites More sharing options...
rondog Posted April 22, 2008 Share Posted April 22, 2008 you probably need some headers like: $headers = "From: someone@domain.com\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1 "; $headers .= "MIME-Version: 1.0 "; mail("them@gmail.com","A new case study has been posted!","Go to <a href="admin.php">the admin page</a> to look it over. It is information regarding $schoolname",$headers); Quote Link to comment Share on other sites More sharing options...
craygo Posted April 22, 2008 Share Posted April 22, 2008 if you are using any kind of html in the email then you have to change header to include it <?php $to = "them@gmail.com"; $subject = "A new case study has been posted!"; $headers = "From: me@gmail.com\r\n"; // used for html don't change //leave the next 2 lines alone $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = "Go to <a href=\"admin.php\">the admin page</a> to look it over. It is information regarding $schoolname"; if(!mail($to, $subject, $message, $headers)){ echo "could not sent E-mail"; } else { echo "Email sent"; } ?> Ray Quote Link to comment Share on other sites More sharing options...
yuckysocks Posted April 22, 2008 Author Share Posted April 22, 2008 I implemented Craygo's code. The variable is converted to the proper word, but the second header (Content-Type: text/html; charset=ISO-8859-1) is just displayed, as opposed to being used as a header. This prevents the link from being converted into a proper anchor element. Thoughts? Thanks so much, Alex Quote Link to comment Share on other sites More sharing options...
GameYin Posted April 23, 2008 Share Posted April 23, 2008 Try using this header instead of those 2 $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=utf-8\r\n"; Quote Link to comment Share on other sites More sharing options...
yuckysocks Posted April 23, 2008 Author Share Posted April 23, 2008 Unfortunately, the second header is still displayed as text at the start of the email (the text/html char encoding one). Any other ideas? This is not a huge deal, but I want the resulting email to be as useful as possible to the recipient (ie, just click a link instead of copy/paste it in). Thanks again for the help, Alex Quote Link to comment Share on other sites More sharing options...
craygo Posted April 23, 2008 Share Posted April 23, 2008 depending on where you send it, sometimes you will have problems with the carriage returns. Try just using \n $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\n"; Ray Quote Link to comment Share on other sites More sharing options...
yuckysocks Posted April 23, 2008 Author Share Posted April 23, 2008 Yes, Yes, 1000 times yes. It's amazing/frustrating/thrilling when just two characters make a script work or not work. Thanks for the continued help and support. Topic Solved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.