phpSensei Posted January 7, 2008 Share Posted January 7, 2008 This is the weirdest, and sorry for my language, but the weirdest shit ever. I don't have experience with mail system, but in this one I changed it from server to server and the mail wont send. It works on one file called signup.php, but when you make a new file and make a mail function it doesnt work. I posted the mail script from my signup.php, and it worked. Then i edited the variables like subject,from,to..etc and it wont send the email. If you undo it to the normal script, it sends the stupid email $to = $to; $subject = $subject; $from = $from; $headers = "From: $from"; $message = "Dear $username, please confirm your account by clicking the following URL:\n\n http://www.shouldidobetter.com/login.php?mode=activate&code=".md5($username)."\n\n\n\n Username = $username Password = $_POST[password] ----------------------------------- Please do not reply to this email, for more contact information, just visit our contact page at http://www.render-works.com/clients/solo_client0001/contact.php"; mail($to,$subject,$message,$headers); Quote Link to comment https://forums.phpfreaks.com/topic/84937-mailing/ Share on other sites More sharing options...
Ken2k7 Posted January 7, 2008 Share Posted January 7, 2008 <?php $to = $to; $subject = $subject; $from = $from; ?> ??? Can you explain those? Quote Link to comment https://forums.phpfreaks.com/topic/84937-mailing/#findComment-433058 Share on other sites More sharing options...
phpSensei Posted January 7, 2008 Author Share Posted January 7, 2008 <?php // Connection $dbh=mysql_connect("localhost", "shouldi_user", "polik12") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("shouldi_db"); $mode = $_GET['do']; $subject = mysql_real_escape_string(strip_tags(ucfirst(strtolower($_POST['subject'])))); $from = $_POST['from']; $to = ($_POST['to']=="all")? "all" : strip_tags($_POST['to']); $message = mysql_real_escape_string(nl2br($_POST['body'])); $headers = "From: $from"; if($mode = "mail"){ if(isset($_POST['Submit'])){ if(empty($subject)){ echo 'Please enter a subject'; }elseif(strlen($subject) > 70){ echo 'Subject must be 70 chars or lower'; }elseif(strlen($subject) < 5){ echo 'Subject must be atleast 5 chars'; }elseif($from == ""){ echo 'Please fill in the from: field'; }elseif(!preg_match("/^[\ a-z0-9._-]+@[a-z0-9.-]+\.[a-z]{2,6}$/i", $from)){ echo 'Please enter a valid email address for the from: field'; }elseif(strlen($message) > 800){ echo 'Sorry, but the message length is too long, please shorten it'; }elseif(strlen($message) < 10){ echo 'Message length must be atleast 10 characters'; }else { if($to == "all"){ $query = mysql_query("SELECT * FROM `mail_list` ORDER BY `date` DESC")or die(mysql_error()); while($row = mysql_fetch_array($query)){ $to = $row['email']; $subject = "$subject"; $message = "$body"; $from = "$from"; $headers = "From: $from"; mail($to,$subject,$message,$headers); $okay = TRUE; $s = "'s"; $were = "were"; } } else { $to = $_POST['to']; $subject = $subject; $from = "brat@shouldidobetter.com"; $headers = "From: $from"; $message = strip_tags($_POST['body']); mail($to,$subject,$message,$headers); $okay = TRUE; $were = "was"; } } } } mysql_close($connection); ?> it works with <?php // Start Session session_start(); $dbh=mysql_connect("localhost", "shouldi_user", "polik12") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("shouldi_db"); $to = "jerose.14@hotmail.com"; $subject = "Confirm Account"; $message = "Dear $username, please confirm your account by clicking the following URL:\n\n http://www.shouldidobetter.com/login.php?mode=activate&code=".md5($username)."\n\n\n\n Username = $username Password = $_POST[password] ----------------------------------- Please do not reply to this email, for more contact information, just visit our contact page at http://www.render-works.com/clients/solo_client0001/contact.php"; $from = "brat@shouldidobetter.com"; $headers = "From: $from"; mail($to,$subject,$message,$headers); die('<!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> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- .style4 { font-size: 36px; color: #b20000; font-family: "Times New Roman", Times, serif; } body { margin-left: 0px; margin-right: 0px; } .underline { border-top: 1px #C4C4C4; border-right: 1px #C4C4C4; border-bottom: 1px dashed #C4C4C4; border-left: 1px #C4C4C4; } .style14 { font-size: 12px; color: #AAAAAA; text-decoration: none; font-family: Tahoma; } .style17 {font-size: 12px; color: #B20000; } .style18 { font-size: 12px; font-family: Georgia, "Times New Roman", Times, serif; font-weight: bold; } .underline_red { border-top: 1px #B20000; border-right: 1px #B20000; border-bottom: 1px dashed #B20000; border-left: 1px #B20000; } .checkbox { background-color: white; border: 1px solid black; } .style14 a:hover { font-size: 12px; color: #B20000; text-decoration: none; font-family: Tahoma; } .style14 a:link { font-size: 12px; color: #AAAAAA; text-decoration: none; font-family: Tahoma; } .style14 a:active { font-size: 12px; color: #AAAAAA; text-decoration: none; font-family: Tahoma; } .style14 a:visited { font-size: 12px; color: #AAAAAA; text-decoration: none; font-family: Tahoma; } a:hover { color: #B20000; } .style28 {color: #B20000} .style34 {font-size: 10px; color: #999999; text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; } .news { border: 2px solid #B20000; } .style37 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } .style46 {color: #0000FF} .style47 {color: #000000} .style48 {color: #707070} .style49 {font-size: 10px; color: #707070; text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; } .style50 {color: #525252} .red_error { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #FF0000; } --> </style> </head> <body><table width="59%" border="0" align="center" cellpadding="0" cellspacing="0" class="news"> <tr> <td height="108" align="center"><div align="center" class="style37">You have successfuly registered your account, to login you need to confirm the account <br /> with the confirmation number sent to your email at.</div></td> </tr> </table></body>'); ?> but if you edit the message, it wont work Quote Link to comment https://forums.phpfreaks.com/topic/84937-mailing/#findComment-433064 Share on other sites More sharing options...
Ken2k7 Posted January 7, 2008 Share Posted January 7, 2008 Shouldn't Password = $_POST[password] be Password = {$_POST['password']} ? Quote Link to comment https://forums.phpfreaks.com/topic/84937-mailing/#findComment-433071 Share on other sites More sharing options...
phpSensei Posted January 7, 2008 Author Share Posted January 7, 2008 Shouldn't Password = $_POST[password] be Password = {$_POST['password']} ? Nevermind those, it works without that, i copied that mail script from the working script. Quote Link to comment https://forums.phpfreaks.com/topic/84937-mailing/#findComment-433072 Share on other sites More sharing options...
Ken2k7 Posted January 7, 2008 Share Posted January 7, 2008 So the top code on your second post is the one NOT working? On that code, (I haven't looked through the whole thing) but you should put if (isset($_POST['submit'])) before all the $_POST calls Also, depending on how big the volume of emails, mail() may not work. Read: http://pear.php.net/package/Mail Quote Link to comment https://forums.phpfreaks.com/topic/84937-mailing/#findComment-433075 Share on other sites More sharing options...
phpSensei Posted January 7, 2008 Author Share Posted January 7, 2008 So the top code on your second post is the one NOT working? On that code, (I haven't looked through the whole thing) but you should put if (isset($_POST['submit'])) before all the $_POST calls Alright, I had a script called signup.php which sends a confirmation email to the regged user, now I made a suscriber application but the emailing wouldnt work. So i took the emailing script from signup.php to test without changing anything from the script. Then i changed the $message variable, and the email wont go through, if you put it back to normal it will work. Validation and everything works... Quote Link to comment https://forums.phpfreaks.com/topic/84937-mailing/#findComment-433080 Share on other sites More sharing options...
phpSensei Posted January 7, 2008 Author Share Posted January 7, 2008 I just tried a simple PHP mail script and still no luck, and SMTP is perfectly supported with the right values Quote Link to comment https://forums.phpfreaks.com/topic/84937-mailing/#findComment-433089 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.