sstangle73 Posted January 20, 2008 Share Posted January 20, 2008 hey everyone making an email script and got a little stuck the email doesnt send <?php if(isset($_POST['email'])){ $to = $_POST['emailto']; $subject = $_POST['subject']; $message = str_replace("\n.", "\n..", $_POST['emailbody']); $from = $_POST['from']; $reply = $_POST['reply']; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: . ' . $from . "\r\n"; $headers .= 'Reply-to: . ' . $reply . "\r\n"; mail($to, $subject, $message, $headers); echo "Success"; } else { ?> <form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post"> <table> <tr><td> <textarea name="emailto" rows="15" cols="50">email@domain.com; email@domain.com; email@domain.com</textarea> </td></tr> <tr><td> <input type="text" name="subject" maxlength="100" value="subject"> </td></tr> <tr><td> <textarea name="emailbody" rows="15" cols="50">Message Here</textarea> </td></tr> <tr><td> <input type="text" name="from" maxlength="100" value="From Name"> </td></tr> <tr><td> <input type="text" name="reply" maxlength="100" value="Reply To"> </td></tr> <tr><td> <input type="submit" name="email" value="Send!"> </td></tr> </table> </form> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/ Share on other sites More sharing options...
PHP Monkeh Posted January 20, 2008 Share Posted January 20, 2008 Are you running this from a webhost or from your localhost? Also are there any error messages being output? Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444536 Share on other sites More sharing options...
sstangle73 Posted January 20, 2008 Author Share Posted January 20, 2008 webhost. whats the error function i havent coded php in a while Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444537 Share on other sites More sharing options...
Tandem Posted January 20, 2008 Share Posted January 20, 2008 put error_reporting(E_ALL); if you don't have any error reporting enabled via your php.ini Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444539 Share on other sites More sharing options...
sstangle73 Posted January 20, 2008 Author Share Posted January 20, 2008 no errors Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444540 Share on other sites More sharing options...
marcus Posted January 20, 2008 Share Posted January 20, 2008 hehe you're trying to do multiple emails. try: <?php $to = $_POST['emailto']; // other variables $ex = explode(";",$to); if(count($ex) > 0){ foreach($ex AS $emails){ $email = trim($emails); mail($email,$subject,$message,$headers); } }else { mail($email,$subject,$message,$headers); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444542 Share on other sites More sharing options...
sstangle73 Posted January 20, 2008 Author Share Posted January 20, 2008 allright it sends. 3 problems: 1) the name and reply to address have a dot before it so if the inputed Name: Joe Smith it comes as .Joe Smith 2) i dont think html works . . . after some test i think i need to add slashes? 3) sometimes its going in my spam folder? Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444552 Share on other sites More sharing options...
ratcateme Posted January 20, 2008 Share Posted January 20, 2008 Do you have access to the mail logs? Scott. Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444553 Share on other sites More sharing options...
sstangle73 Posted January 20, 2008 Author Share Posted January 20, 2008 doubt it. i can check tho Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444554 Share on other sites More sharing options...
marcus Posted January 20, 2008 Share Posted January 20, 2008 If you make your message using HTML, just use nl2br() on it. Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444556 Share on other sites More sharing options...
sstangle73 Posted January 20, 2008 Author Share Posted January 20, 2008 the html is working as long as i dont use ' or " in the message. Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444557 Share on other sites More sharing options...
marcus Posted January 20, 2008 Share Posted January 20, 2008 Um, use htmlentities() on your message Converts characters of such, so " -> " Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444558 Share on other sites More sharing options...
sstangle73 Posted January 20, 2008 Author Share Posted January 20, 2008 i just need to use add slashes. because i want the " or 's for the html code. like <img src="blah"> i need the "s Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444560 Share on other sites More sharing options...
sstangle73 Posted January 20, 2008 Author Share Posted January 20, 2008 thats not my main focas tho. i can do crappy html with out " or ' thats fine. i want to fix the .From and .Reply-to first if you can help me with that? Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444564 Share on other sites More sharing options...
sstangle73 Posted January 20, 2008 Author Share Posted January 20, 2008 allright i found where the dots were coming from does anyone know why it gets flagged as spam? and also how do i send a html message with <img src"blah"> because "s mess up the script <?php error_reporting(E_ALL); if(isset($_POST['email'])){ $to = $_POST['emailto']; $subject = $_POST['subject']; $amessage = nl2br($_POST['emailbody']); $message = addslashes($amessage); $from = $_POST['from']; $reply = $_POST['reply']; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ' . $from . "\r\n"; $headers .= 'Reply-to: ' . $reply . "\r\n"; $ex = explode(";",$to); if(count($ex) > 0){ foreach($ex AS $emails){ $email = trim($emails); mail($email,$subject,$message,$headers); } }else { mail($email,$subject,$message,$headers); } echo "Success"; } else { ?> <form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post"> <table> <tr><td> <textarea name="emailto" rows="15" cols="50">email@domain.com; email@domain.com; email@domain.com</textarea> </td></tr> <tr><td> <input type="text" name="subject" maxlength="100" value="subject"> </td></tr> <tr><td> <textarea name="emailbody" rows="15" cols="50">Message Here</textarea> </td></tr> <tr><td> <input type="text" name="from" maxlength="100" value="From Name"> </td></tr> <tr><td> <input type="text" name="reply" maxlength="100" value="Reply To"> </td></tr> <tr><td> <input type="submit" name="email" value="Send!"> </td></tr> </table> </form> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444571 Share on other sites More sharing options...
sstangle73 Posted January 20, 2008 Author Share Posted January 20, 2008 fixed spam problem the only problem left is the <img src="blah"> the "s will mess it up any fixes? Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444598 Share on other sites More sharing options...
sstangle73 Posted January 21, 2008 Author Share Posted January 21, 2008 ideas? Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444703 Share on other sites More sharing options...
sstangle73 Posted January 21, 2008 Author Share Posted January 21, 2008 noone? Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-444808 Share on other sites More sharing options...
sstangle73 Posted January 21, 2008 Author Share Posted January 21, 2008 ? Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-445144 Share on other sites More sharing options...
adam291086 Posted January 21, 2008 Share Posted January 21, 2008 What happens when you add the line <img src="blah"> the "s will mess it up any fixes? Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-445146 Share on other sites More sharing options...
sstangle73 Posted January 21, 2008 Author Share Posted January 21, 2008 the image isnt displayed its just a blank email Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-445150 Share on other sites More sharing options...
adam291086 Posted January 21, 2008 Share Posted January 21, 2008 i know that some email clients prevent images from being recieved to speed up downloading time. I take it the message comes from the database with the variable $amessage. Have you tried to echo that variable out to look and what it displays? Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-445153 Share on other sites More sharing options...
sstangle73 Posted January 21, 2008 Author Share Posted January 21, 2008 no ill do that. but when i send it with out "s ie: <img src=blah> it will send so its somethign with the quotes. Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-445155 Share on other sites More sharing options...
adam291086 Posted January 21, 2008 Share Posted January 21, 2008 try this then <img src=\"blah\"> Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-445159 Share on other sites More sharing options...
sstangle73 Posted January 21, 2008 Author Share Posted January 21, 2008 heh the slashes were the problem i needed to strip them before it sent it. thanks Quote Link to comment https://forums.phpfreaks.com/topic/86951-email/#findComment-445162 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.