jmcall10 Posted June 13, 2006 Share Posted June 13, 2006 I have this code[code]$to = "email@emailaddress.com";$subject = "Test email"; $message = "$mailMessage"; $headers = "From: email@emailaddress.com";$headers .= "\nReply-To: email@emailaddress.com"; $sentOk = mail($to,$subject,$message,$headers);[/code]I have $mailMessage as a text area input.The email sends ok but what I want it to do is for me to be able to put html code in the text area.i.e if I put [code]<a href="http://www.phpfreaks.com">phpfreaks</a>[/code]I want it to be read like [a href=\"http://www.phpfreaks.com\" target=\"_blank\"]phpfreaks[/a]any ideasThanks in advancejmcall10 Quote Link to comment https://forums.phpfreaks.com/topic/11889-php-mail-function-question/ Share on other sites More sharing options...
nogray Posted June 13, 2006 Share Posted June 13, 2006 Just add this to the header[code]$headers .= 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";[/code]and you should be able to send html Quote Link to comment https://forums.phpfreaks.com/topic/11889-php-mail-function-question/#findComment-45112 Share on other sites More sharing options...
jmcall10 Posted June 13, 2006 Author Share Posted June 13, 2006 Thanks for that however I have a strange problemWhen I use[code]<a href="http://www.phpfreaks.com>phpfreaks</a>[/code]The link is clickable in outlook but when I view the email in hotmail the link is the colour of a link but is not clickable?I have checked hotmail settings and cant find anythingalso when I check lycos mail it is not even the colour of a link?Any ideasthanks in advancejmcall10 Quote Link to comment https://forums.phpfreaks.com/topic/11889-php-mail-function-question/#findComment-45118 Share on other sites More sharing options...
Buyocat Posted June 13, 2006 Share Posted June 13, 2006 You're missing the second quotation mark on the <a> replace your link with:<a href="phpfreaks.com">phpfreaks</a>or something like that. Quote Link to comment https://forums.phpfreaks.com/topic/11889-php-mail-function-question/#findComment-45128 Share on other sites More sharing options...
jmcall10 Posted June 13, 2006 Author Share Posted June 13, 2006 Yeah I just type that one up for an example that wasnt the one Im usingThe code in the one I use has both quotation marksThanks in advancejmcall10 Quote Link to comment https://forums.phpfreaks.com/topic/11889-php-mail-function-question/#findComment-45131 Share on other sites More sharing options...
jmcall10 Posted June 13, 2006 Author Share Posted June 13, 2006 Here is the new code I have.Can someone tell me whats wrong[code]$to = "email@emailaddress.com";$subject = "$mailSubject";$message = "$mailMessage";$headers = "From: email@emailaddress.com";$headers .= "\nReply-To: email@emailaddress.com";$headers .= "\nMIME-Version: 1.0";$headers .= "\nContent-type: text/html; charset=iso-8859-1";$sentOk = mail($to,$subject,$message,$headers);[/code]Thanks in advancejmcall10 Quote Link to comment https://forums.phpfreaks.com/topic/11889-php-mail-function-question/#findComment-45144 Share on other sites More sharing options...
nogray Posted June 13, 2006 Share Posted June 13, 2006 Hotmail usually disable HTML content unless you click enable HTML content (I think that's what it's called). It's not your script, but hotmail filters. Quote Link to comment https://forums.phpfreaks.com/topic/11889-php-mail-function-question/#findComment-45151 Share on other sites More sharing options...
jmcall10 Posted June 13, 2006 Author Share Posted June 13, 2006 So how come any other email I get via hotmail the links work? Quote Link to comment https://forums.phpfreaks.com/topic/11889-php-mail-function-question/#findComment-45171 Share on other sites More sharing options...
nogray Posted June 13, 2006 Share Posted June 13, 2006 There are a lot of factors when it comes to filtering email.It depends if the email in the Junk folder or the inbox. If the sender in a black list, or not, the IP address of the sender, the headers, the format of the message.In your message, try to add[code]<html><head><title>Message</title></head><body>YOUR Message</body></html>[/code]Even though everything above the body tag get stripped, this should lower the spam filter points. Quote Link to comment https://forums.phpfreaks.com/topic/11889-php-mail-function-question/#findComment-45174 Share on other sites More sharing options...
jmcall10 Posted June 13, 2006 Author Share Posted June 13, 2006 ok still no such luck. I will post all the code within the function I use and maybe it will make more senseIf someone could try it out I wud be much appreciatedI have a database with a table called 'mail_members2' in the table are 3 fields: 'mail_id', 'mail_name' and 'mail_address'The code takes in the subject and the text and mails it out to all in table.Only thing that doesnt work for me is when I use html link code.[code]function newsletter(){global $config, $subject,$mailSubject, $message, $mailMessage; if (is_loggedin()) { if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($mailSubject == "" || $mailMessage == "") { echo " <html> <body>"; echo" We are sorry but the subject or message field was empty! </body> </html>"; } else { mysql_connect($config['sql_host'], $config['sql_username'], $config['sql_password']); mysql_select_db($config['sql_database']); $query = mysql_query("SELECT * FROM `mail_members2`"); $num_rows = mysql_num_rows($query); while ($row = mysql_fetch_array($query)) { $to = "$row[mail_address]"; $subject = "$mailSubject"; $message = "Hey " . $row[mail_name]."<br>"; $message .= "$mailMessage"; $headers = "From: admin@somesite.com"; $headers .= "\nReply-To: admin@somesite.com"; $headers .= "\nMIME-Version: 1.0"; $headers .= "\nContent-type: text/html; charset=iso-8859-1"; $sentOk = mail($to,$subject,$message,$headers); } echo " <html> <body>"; echo" NewsLetter has been sent! </body> </html>"; } } else { echo " <html> <body>"; echo" <form method=\"post\" action=\"?act=newsletter\"> <table> <tr> <td >Subject:</td> <td ><input type=\"text\" name=\"mailSubject\" size=\"20\"></td> </tr> <tr> <td >Message:</td> <td ><textarea rows=\"19\" name=\"mailMessage\" cols=\"60\"></textarea></td> </tr> </table> <input type=\"submit\" value=\"Send NewsLetter\" > </body> </html>"; }} else { echo " <html> <body> You are not logged in. </body> </html>"; }}[/code]The code is part of a larger set of code that requires a log in. Simply strip the code accordinglyI would really appreciate help on this matterThanks in advancejmcall10 Quote Link to comment https://forums.phpfreaks.com/topic/11889-php-mail-function-question/#findComment-45241 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.