HoTDaWg Posted April 1, 2007 Share Posted April 1, 2007 is it my script thats wrong, because it does not send the email but inserts the data into the db...could it be the code? <?php $ip = $_SERVER['REMOTE_ADDR']; $date = date('l F, Y @ g:i:s A e'); $sitename = "*******"; $slogan = "Making Pixels Dance."; $subscribetext= "Join...NOW!"; $emailform = '<form method="POST" name="addsubscriber" action="'.$_SERVER['PHP_SELF'].'?mode=emailsubmit"><br>'.$subscribetext.'<br>Email:<input name="emailaddress" maxlength="80" value="'.$email.'"><br><input type="submit" value="Submit!"></form>'; $conn = mysql_connect("localhost","********","****************"); mysql_select_db("**************); $adminemail = '****************'; define(inStereo,true); $mode = $_GET['mode']; switch ($mode){ case 'emailsubmit': $email = $_POST['emailaddress']; $emailerror = array(); if(empty($email)){ $emailerror['email'] .= '<li><font color="#FF0000">The Email field was was not complete</font></li>'; } if(strlen($email) > 80){ $emailerror['email'] .= '<li><font color="#FF0000">The Email field exeeds the limit of 80 characters</font></li>'; } if(preg_match('|[^-_.@a-z\d]|i', $email)){ $emailerror['email'] .= '<li><font color="#FF0000">The Email Field contains invalid characters. Alphanumeric, @,-,and _ characters are the only characters accepted due to security reasons.</font></li>'; } $emailexists = "SELECT email FROM subscribers WHERE email='$email'"; $selectemailexists = mysql_query($emailexists,$conn); if(mysql_num_rows($selectemailexists) > 0){ $emailerror['email'] .='<li><font color="#FF0000">This Email is already registered as a subscriber.</font></li>'; } if(count($emailerror) < 1){ $usercode = rand(0,1000000); $status = 'blank'; $insertemail = "INSERT INTO subscribers(`id`,`email`,`usercode`,`date`,`ip`,`status`) VALUES('','$email','$usercode','$date','$ip','$status')"; $insertemailnow = mysql_query($insertemail,$conn); if($insertemailnow){ $message="Thanks for registering on our website! Open a new window and go to http://www.slicksilver.uni.cc/index.php?email=$email&mode=verify&usercode=$usercode to complete your registration. Thanks."; $to = &$email; $subject = 'Validate This Email'; $headers = 'From: *******' . "\r\n" . 'Reply-To: *************' . "\r\n" . //This statement helps out with spam filters 'X-Mailer: PHP/' . phpversion(); //Send the email mail($to, $subject, $message, $headers); $contentecho .='Thank you for registering. A verification email has been dispatched to your email address. Please check your spam/junk mail folders if the email does not appear in your inbox. If the email does not appear at all within 24 hours contact the administrator. Thanks again.'; }else{ $contentecho .='An error occurred with your submission. Please try again.'; } }else{ foreach ($emailerror as $error){ $echoemailerrors .= ''.$error.''; } $content = array(); $content['text'] .= 'The following errors were found in your submission:<br>'.$echoemailerrors.'<br>'; $content['text'] .= ''.$emailform.''; foreach ($content as $text){ $contentecho .= ''.$text.''; } } break; case 'verify': $usercode = $_GET['usercode']; $email = $_GET['email']; $validateerror = array(); if(empty($usercode) || empty($email)){ $validateerror['empty'] .= '<li><font color="#FF0000">This page was accessed incorrectly.</font></li>'; } $validatetrue = "SELECT email,usercode FROM subscribtions WHERE email='$email' usercode='$usercode' status='good'"; $validatetruenow = mysql_query($validatetrue,$conn); if(mysql_num_rows($validatetruenow) > 0){ $validateerror['already_exists'] .= '<li><font color="#FF0000">This email is already subscribed and validated.</font></li>'; } if(count($validateerror) > 0){ $status = "good"; $updateemail = "UPDATE subscribers SET status='$status' WHERE usercode='$usercode'"; $updatemailnow = mysql_query($insertemail,$conn); if($updateemailnow){ $action = "New Email added to subscribers list"; $insertaction = "INSERT INTO actions(`id`,`action`,`date`,`ip`) VALUES('','$action','$date','$ip')"; $actionsubmit = mysql_query($insertaction,$conn); if($actionsubmit){ $contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.'; }else{ $contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.'; } }else{ $contentecho .='<li><font color="#FF0000">An error occurred with your verification. Please try again.</font></li>'; } }else{ foreach($validateerror as $errorkind){ $contentecho .= ''.$errorkind.''; } } break; default: $contentecho .=''.$emailform.''; break; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Welcome!</title> </head> <body bgcolor="#999999" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <center> <table width="750" height="0" cellpadding="0" cellspacing="0" border="0" style="Border: 1px solid #000000;"> <tr> <td bgcolor="#666666" valign="top"><font color="#FFFFFF" face="arial"><b>Under construction</font></b></td> </tr> <tr> <td bgcolor="#cccccc" valign="top"> <table width="98%" border="0"> <font face="arial" size="3"> Our website is under construction, bare with us as we create it.<b>Thanks for your consideration.</b><br> <b>Check back soon!</b><br><br> <i>The <?php echo $sitename; ?> Team</i></font> </table> </td> </tr> <tr> <td bgcolor="#0099FF" valign="top"><font color="#FFFFFF" size="3" face="arial"><B>Sign up for email updates today!</B></font></td> </tr> <tr> <td bgcolor="#CCCCCC" valign="top"> <center> <table width="98%" border="0"> <?php echo $contentecho; ?> </table> </center> </td> </tr> </table> </center> <h4 align="center">Our website is graciously hosted by <a href="http://guildwutang.com/">X ER Game Hosting</a></h4> </body> </html> ...any ideas? specifically the mail code is: <?php $message="Thanks for registering on our website! Open a new window and go to http://www.slicksilver.uni.cc/index.php?email=$email&mode=verify&usercode=$usercode to complete your registration. Thanks."; $to = &$email; $subject = 'Validate This Email'; $headers = 'From: *******' . "\r\n" . 'Reply-To: *************' . "\r\n" . //This statement helps out with spam filters 'X-Mailer: PHP/' . phpversion(); //Send the email mail($to, $subject, $message, $headers); ?> I have been testing it out in GMail because in my opinion it is the most leniant. thanks for any help possible. .-=<!--HoTDaWg--!>=-. Quote Link to comment Share on other sites More sharing options...
per1os Posted April 2, 2007 Share Posted April 2, 2007 try this mail($to, $subject, $message, $headers, "-fyou@fromaddress.com"); Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 2, 2007 Share Posted April 2, 2007 Use new mail() Instead Of mail() It will help you find the errors. -------------------------------------------------------------- <?php $mail = new mail("admin@localhost", "Subject", "Mail Body"); //3 Arguments Are Given //$mail = new mail("to@domain", "Mail Subject", "Mail Body"); if($mail->send()) { echo "Mail Sent Succfully\n"; } else { echo "Sorry Mail Sending Failed\n"; print_r($mail->error);//Print The Errors } ?> more Info But You have to include 3 files config.php, mail/mail.php, done.php more info Download Those Files from here 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.