Jump to content

[SOLVED] sending mail


sw45acp

Recommended Posts

hi,

im trying to send an email confirmation link to someone when they want to change their email address. when I include a link in the email, it does not send!

 

if (isset($_POST["change_email"]))
{
$token = $_POST["token"];

//generate unique id
$uid = md5(uniqid(rand(), true));
$sql = mysql_query("UPDATE admin SET `uid` = '$uid' WHERE `password` = '$token'");
if (!$sql)
{
	die('Could not execute query!: ' . mysql_error());
	mysql_close($con);
}
else
{
	mysql_close($con);
	$email = $_POST["email"];
	//compose email parts
	$subject = "MHS WTP Control Panel";
	$header = "You have changed your login email address for the control panel.";
	$message = "Please confirm this change by clicking the link below:\r\n";
	$message .= "https://mhswtpmanage.c6.ixwebhosting.com/cp_info.php?token=$token&uid=$uid";

                //if $message was "http://www.google.com/" it works, or if it was "bla sldjfalkdjf" it works.
                //but it doesnt work with that url. I don't think secure connections have anything to do with it

	ini_set('sendmail_from','webmaster@mhswethepeople.com');
	$sentmail = mail($email,$subject,$message,$header);
	if (!$sentmail)
	{
		die('Could not send mail');
	}
	else
	{
		//continue on to next page
	}
}
}

 

maybe it is because the send mail function is too deep into the code, i dont know.

any ideas?

Link to comment
Share on other sites

Try:

if (isset($_POST["change_email"]))
{
$token = $_POST["token"];

//generate unique id
$uid = md5(uniqid(rand(), true));
$sql = mysql_query("UPDATE admin SET `uid` = '$uid' WHERE `password` = '$token'");
if (!$sql)
{
	die('Could not execute query!: ' . mysql_error());
	mysql_close($con);
}
else
{
	mysql_close($con);
	$email = $_POST["email"];
	//compose email parts
	$subject = "MHS WTP Control Panel";
	$header = "You have changed your login email address for the control panel.";
	$message = "Please confirm this change by clicking the link below:\r\n";
	$message .= '<a href="https://mhswtpmanage.c6.ixwebhosting.com/">https://mhswtpmanage.c6.ixwebhosting.com/</a>';

                //if $message was "http://www.google.com/" it works, or if it was "bla sldjfalkdjf" it works.
                //but it doesnt work with that url. I don't think secure connections have anything to do with it

	ini_set('sendmail_from','webmaster@mhswethepeople.com');
	$sentmail = mail($email,$subject,$message,$header);
	if (!$sentmail)
	{
		die('Could not send mail');
	}
	else
	{
		//continue on to next page
	}
}
}

Link to comment
Share on other sites

commenting that out either doesn't work, because it doesn't send it at all

if (isset($_POST["change_email"]))

{

$token = $_POST["token"];

 

//generate unique id

$uid = md5(uniqid(rand(), true));

$sql = mysql_query("UPDATE admin SET `uid` = '$uid' WHERE `password` = '$token'");

if (!$sql)

{

die('Could not execute query!: ' . mysql_error());

mysql_close($con);

}

else

{

mysql_close($con);

$email = $_POST["email"];

//compose email parts

$subject = "MHS WTP Control Panel";

$headers= "You have changed your login email address for the control panel.";

$message = "Please confirm this change by clicking the link below:\r\n";

$message .= '<a href="https://mhswtpmanage.c6.ixwebhosting.com/">https://mhswtpmanage.c6.ixwebhosting.com/</a>';

 

//ini_set('sendmail_from','webmaster@mhswethepeople.com');

$sentmail = mail($email,$subject,$message,$headers);

if (!$sentmail)

{

die('Could not send mail');

}

else

{

//continue on to next page

}

}

}

Link to comment
Share on other sites

oh! sorry here is the source for this one

<?php
if (isset($_POST["submit"]))
{
$email = $_POST["email"];

//gather parts
$subject = "test";
$header = "more test";
$message = "even more test\r\n";
$message .= '<a href="http//www.google.com/">Google</a>';

ini_set('sendmail_from','webmaster@mhswethepeople.com');
$sentmail = mail($email,$subject,$message,$header);
if (!$sentmail)
{
	echo "Could not send mail";
}
else
{
	echo "Sent mail, and the link does appear this time.<br />";
	echo $subject . "<br />" . $header . "<br />" . $message . "<br />";
}
}
?>

Link to comment
Share on other sites

OK.  Try this:

 

if (isset($_POST["change_email"]))
{
   $token = $_POST["token"];
   
   //generate unique id
   $uid = md5(uniqid(rand(), true));
   $sql = mysql_query("UPDATE admin SET `uid` = '$uid' WHERE `password` = '$token'");
   if (!$sql)
   {
      die('Could not execute query!: ' . mysql_error());
      mysql_close($con);
   }
}//end of if(isset($_POST["change_email"]))
else
{
      $email = $_POST["email"];
      //compose email parts
      $subject = "MHS WTP Control Panel";
      $headers = 'From: webmaster@mhswethepeople.com';
      $message = "Please confirm this change by clicking the link below:\r\n";
      $message .= 'https://mhswtpmanage.c6.ixwebhosting.com/';
      
      //ini_set('sendmail_from','webmaster@mhswethepeople.com');
      $sentmail = mail($email,$subject,$message,$headers);
      if (!$sentmail)
      {
         die('Could not send mail');
      }
      else
      {
         //continue on to next page
      }
}//end of else


Link to comment
Share on other sites

no luck man. I also tried reducing it just down to this:

if (isset($_POST["change_email"]))
{

$email = $_POST["email"];
//compose email parts
$subject = "MHS WTP Control Panel";
$headers = "You have changed your login email address for the control panel.";
$message = "Please confirm this change by clicking the link below:\r\n";
$message .= '<a href="https://mhswtpmanage.c6.ixwebhosting.com/">https://mhswtpmanage.c6.ixwebhosting.com/cp_info.php</a>';

//ini_set('sendmail_from','webmaster@mhswethepeople.com');
        //doesnt work whether I have ini_set in there or not


$sentmail = mail($email,$subject,$message,$headers);
if (!$sentmail)
{
	die('Could not send mail');
}
else
{
	echo "all good";
}
}

 

Link to comment
Share on other sites

ive reduced it down further to this, and removed the outside if() condition

no success yet

<?php

<?php
$email = $_POST["email"];
//compose email parts
$subject = "MHS WTP Control Panel";
$message = "Please confirm this change by clicking the link below:\r\n";
$message .= '<a href="https://mhswtpmanage.c6.ixwebhosting.com/">https://mhswtpmanage.c6.ixwebhosting.com/cp_info.php</a>';

ini_set('sendmail_from','webmaster@mhswethepeople.com');
$sentmail = mail($email,$subject,$message);
if (!$sentmail)
{
die('Could not send mail');
}
else
{
echo "all good";
}
?>

?>

Link to comment
Share on other sites

positive that $email is not empty. I think maybe something is wrong w/ the server. Because even this simple page doesnt do it.

<?php
if (isset($_POST["submit"]))
{
$email = $_POST["email"];
//compose email parts
$subject = "MHS WTP Control Panel";
$message = "Please confirm this change by clicking the link below:\r\n";
$message .= '<a href="https://mhswtpmanage.c6.ixwebhosting.com/cp_info.php">https://mhswtpmanage.c6.ixwebhosting.com/cp_info.php</a>';

ini_set('sendmail_from','webmaster@mhswethepeople.com');
$sentmail = mail($email,$subject,$message);
if (!$sentmail)
{
die('Could not send mail');
}
else
{
echo "all good" . "<br />";
}
}
?>
<html>
<head>
</head>
<body>
<form action="test2.php" method="post">
Enter email:<br />
<input type="text" name="email" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>

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.