Jump to content

sending SMTP email deletes cookies?


JKG

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
}
?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.