RaythMistwalker Posted February 28, 2010 Share Posted February 28, 2010 <?php if(isset($_POST['request2'])) { $to = "[email protected]"; $subject = "DJ Thunder Radio Request"; $name_field = $_POST['name']; $artist = $_POST['songartist']; $title = $_POST['songtitle']; $email_field = $_POST['email']; $message = $_POST['message']; $headers = 'From: '.$email_field . "\r\n" . 'Reply-To: '.$email_field . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $body = "DJ Thunder has recieved a radio Request:\nRequest By: $name_field\nE-Mail: $email_field\nSong: $artist - $title\nMessage/Dedication:\n$message"; mail($to, $subject, $body, $headers, '[email protected]'); $error = 'Request Sent.'; } if (isset($_POST['request'])) { $artist = $_POST['songartist']; $title = $_POST['songtitle']; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>DJ Thunder</title> <link href="../red.css" rel="stylesheet" type="text/css" /> </head> <body text="#0000ff" link="#00a5e9" vlink="#00a5e9" alink="#00a5e9" leftmargin="2" topmargin="2" marginwidth="2" marginheight="0"> <center><h1>DJ Thunder</h1></center> <table width=100% class='tableborder'><tr><td valign=top width=27%><div class='navigation'>Links</div><br> <a href='index.php'>Home</a><br> <a href='playlist.php'>Playlist</a><br> <a href='request.php'>Request a Song</a><br> <a href='http://rockinradio.net' target='blank'>Rockin Radio</a><br> </td><td width=73%> <? if (!$error) { ?> <p><b>Fill in the form Below.</p> <center><form action="" method=post> <table class='tableborder'> <tr><td>Name:</td><td align=left><input type='text' name='name'> </td></tr> <tr><td>Email Address:</td><td align=left><input type='text' name='email'></td></tr> <tr><td>Artist:</td><td align='left'><input type='text' name='songartist' <? if ($artist) { echo "value='".$artist."'"; } ?>> <tr><td>Title:</td><td align='left'><input type='text' name='songtitle' <? if ($title) { echo "value='".$title."'"; } ?>> <tr><td>Message/Dedication Message:</td><td align=left><textarea rows="9" name="message" cols="30"></textarea></td></tr> </table></center> <input type='submit' name='request2' value='Request'></form> <? } else { echo $error; } ?> </table> </body> </html> For some reason this code stopped sending emails. I copied it from another part of my website and modified slightly and doesn't work and neither does the original which is strange because the original used to work. Quote Link to comment https://forums.phpfreaks.com/topic/193707-email-code-suddenly-stopped-working/ Share on other sites More sharing options...
jl5501 Posted February 28, 2010 Share Posted February 28, 2010 ok first question. Has any server side software recently been upgraded? Quote Link to comment https://forums.phpfreaks.com/topic/193707-email-code-suddenly-stopped-working/#findComment-1019595 Share on other sites More sharing options...
RaythMistwalker Posted February 28, 2010 Author Share Posted February 28, 2010 not as far as i know. though i've been on holiday for 2 weeks but i havent recieved an email from the host sayin so Quote Link to comment https://forums.phpfreaks.com/topic/193707-email-code-suddenly-stopped-working/#findComment-1019598 Share on other sites More sharing options...
PFMaBiSmAd Posted February 28, 2010 Share Posted February 28, 2010 For debugging purposes only, what does putting the following two lines of code in immediately after the line with your first opening <?php tag show (test with an entered email address that is not hosted at your sending mail server) - ini_set("display_errors", "1"); error_reporting(E_ALL); The From: address put into the header should be a valid email address hosted at the sending mail server, even if you are sending email to yourself. When you put the arbitrary email address that is entered in form in as the From: address you risk getting the emails marked as spam and after a number of such miss-addressed emails a lot of the major ISP's will ban mail coming from your mail server. Your code is also not validating any of the entered values being put into the header so a spammer(s) could have been sending their email through your mail server, thereby getting it banned. Quote Link to comment https://forums.phpfreaks.com/topic/193707-email-code-suddenly-stopped-working/#findComment-1019605 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.