JKG Posted August 25, 2011 Share Posted August 25, 2011 Is this true, i have cookies on my site till i send a form which fires off two emails. the cookies are not only deleted, but i can reset the cookie to the proper values unless i delete all my cookies!! any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/245703-sending-smtp-email-deletes-cookies/ Share on other sites More sharing options...
WebStyles Posted August 25, 2011 Share Posted August 25, 2011 sounds weird. should have nothing to do with sending the emails. Sure you dont have other code executing? comment out the two lines that send the emails and try again. if you still lose your cookies, it's not the emails. otherwise post your code here so we can have a look. Quote Link to comment https://forums.phpfreaks.com/topic/245703-sending-smtp-email-deletes-cookies/#findComment-1261965 Share on other sites More sharing options...
JKG Posted August 25, 2011 Author Share Posted August 25, 2011 it IS strange!! i followed your suggestion and just commented out $mail->Send(); and the cookie is still in tact after sending the form!! any thoughts? thanks, Joe. Quote Link to comment https://forums.phpfreaks.com/topic/245703-sending-smtp-email-deletes-cookies/#findComment-1261971 Share on other sites More sharing options...
WebStyles Posted August 25, 2011 Share Posted August 25, 2011 wanna share the code that's on the page sending the emails? Quote Link to comment https://forums.phpfreaks.com/topic/245703-sending-smtp-email-deletes-cookies/#findComment-1261973 Share on other sites More sharing options...
JKG Posted August 25, 2011 Author Share Posted August 25, 2011 the cookie before and after actually contains the same data which is strange. the code is: (with private project details stripped) <?php require_once $root_dir . $html_dir . $scripts_dir . 'class.phpmailer.php'; if(isset($_POST['submit_send_form'])){ $contact_id = trim($_COOKIE['contact_ids'], ','); $message = 'message here'; $mail = new PHPMailer(); //Your SMTP servers details $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "localhost"; // specify main and backup server $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = ""; // SMTP username $mail->Password = ""; // SMTP password //It should be same as that of the SMTP user $mail->From = ""; $mail->FromName = ""; //where you wish to receive those emails. //$mail->AddAddress($_POST['userEmail'], $_POST['userName']); $mail->AddAddress($_POST['userEmail'], $_POST['userName']); $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML(true); // set email format to HTML $mail->Subject = ''; $mail->Body = $message; $mail->Send(); $message_suppliers = ''; $mail_suppliers = new PHPMailer(); //Your SMTP servers details $mail_suppliers->IsSMTP(); // set mailer to use SMTP $mail_suppliers->Host = "localhost"; // specify main and backup server $mail_suppliers->SMTPAuth = true; // turn on SMTP authentication $mail_suppliers->Username = ""; // SMTP username $mail_suppliers->Password = ""; // SMTP password //It should be same as that of the SMTP user $mail_suppliers->From = ""; $mail_suppliers->FromName = ""; //where you wish to receive those emails. //$mail_suppliers->AddAddress($_POST['userEmail'], $_POST['userName']); if(!empty($contact_id)){ $grabPhotographer = good_query_table("SELECT * FROM `users` WHERE `ID` in ($contact_id)"); foreach ($grabPhotographer as $displayPhotographerEmail){ $mail_suppliers->AddBCC($displayPhotographerEmail['Email'], $displayPhotographerEmail['business_name']); }; }; /* if(!empty($videographers)){ $grabVideographer = good_query_table("SELECT * FROM `users` WHERE `ID` in (".substr($contact_vid_id, 0, -1).")"); foreach ($grabVideographer as $displayVideographerEmail){ $mail_suppliers->AddBCC($displayVideographerEmail['Email'], $displayVideographerEmail['business_name']); }; };*/ $mail_suppliers->WordWrap = 50; // set word wrap to 50 characters $mail_suppliers->IsHTML(true); // set email format to HTML $mail_suppliers->Subject = ''; $mail_suppliers->Body = $message_suppliers; $mail_suppliers->Send(); mysql_query("INSERT INTO ``.`` (`id`, `name`, `email`, `message`, `userWeddingDate`, `timestamp`, `toIDs`, `type`) VALUES (NULL, '".mysql_real_escape_string($_POST['userName'])."', '".mysql_real_escape_string($_POST['userEmail'])."', '".mysql_real_escape_string($_POST['userMessage'])."', '".mysql_real_escape_string($_POST['selectedDate'])."', CURRENT_TIMESTAMP, '".$contact_id."', '1');") or die("SQL Error: " . mysql_error()); ?> <h1>complete!</h1> <fieldset> <div class="success-box">All the details of the suppliers you selected have been sent to <?php echo $_POST['userEmail']; ?>. </div> <div class="success-box">Your message has been sent to the selected suppliers. </div> <div class="info-box">If you do not receive your email, please check your junk/spam email folders. Thank you.</div> </fieldset> <?php }elseif(!isset($_POST['selectedDate'])){ echo '<h1>Error</h1> <fieldset> <p>Your session has expired, please <a title="" href="'.$html_dir.$prerewrite.$link_home.$postrewrite.'">click here</a> to return home. Sorry for any inconvenience.</p> </fieldset>'; }else{ ?> <h1>contact selected photographers</h1> <fieldset> <p>Fill out the below form to send a message to the selected suppliers. We will never pass on your email address to anyone who you have not specified.</p> <p> </p> <form method="post" class="formular" id="use-validator" action="<?php echo $_SERVER['REQUEST_URI']?>"> <input type="hidden" name="selectedDate" value="<?php echo $_POST['selectedDate']; ?>"/> <p>your name*<br /> <input class="validate[required] text-input" id="userName" name="userName" type="text" /> <p>your email address*<br /> <input class="validate[required,custom[email]] text-input" id="userEmail" name="userEmail" type="email" /> <p>your message<br /> <textarea name="userMessage"></textarea> <p><input type="submit" name="submit_send_form" class="submit" value="send me the details!"/> </form> <p class="small">* indicates a required field</p> </fieldset> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/245703-sending-smtp-email-deletes-cookies/#findComment-1261975 Share on other sites More sharing options...
xyph Posted August 25, 2011 Share Posted August 25, 2011 I've never heard issues of the PHPMailer class destroying cookies. I've used it myself and have never encountered such an issue. Is there any Javascript interaction with cookies? Have you tried this on other machines to verify it's not a local issue? Quote Link to comment https://forums.phpfreaks.com/topic/245703-sending-smtp-email-deletes-cookies/#findComment-1262031 Share on other sites More sharing options...
JKG Posted August 25, 2011 Author Share Posted August 25, 2011 turns out the script relies on register_globals, so the data was not being sent through as this was disabled server wide. this guide helped: http://ukwebsolutionsdirect.co.uk/portal/knowledgebase/181/suPHP-What-is-it-and-how-does-it-affect-my-site.php Quote Link to comment https://forums.phpfreaks.com/topic/245703-sending-smtp-email-deletes-cookies/#findComment-1262039 Share on other sites More sharing options...
xyph Posted August 25, 2011 Share Posted August 25, 2011 If it's not your code, please let us know next time, or we will make assumptions. register_globals has been officially depreciated, and has been turned off by default with a strong suggestion to leave it off since PHP 4.2 (2002) You should never use register globals. If you do, know exactly why you are using it, and define default values (declare, in some sense) for EVERY variable you use, with the exception of variables you expect to be user-input. Quote Link to comment https://forums.phpfreaks.com/topic/245703-sending-smtp-email-deletes-cookies/#findComment-1262045 Share on other sites More sharing options...
JKG Posted August 26, 2011 Author Share Posted August 26, 2011 all that code i posted was my code. i was referring to the mailer classes. (who would write their own SMTP mailer class???) Quote Link to comment https://forums.phpfreaks.com/topic/245703-sending-smtp-email-deletes-cookies/#findComment-1262299 Share on other sites More sharing options...
JKG Posted August 26, 2011 Author Share Posted August 26, 2011 just an update: i have since turn register_globals off (cos its v. dangerous) as I updated the mailer class and that solved the issue. Quote Link to comment https://forums.phpfreaks.com/topic/245703-sending-smtp-email-deletes-cookies/#findComment-1262318 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.