Jump to content

email function, how to get it working


garydt

Recommended Posts

I'm trying to get php to email me. I'm getting no errors but i'm not recieving any emails either.

$to = "[email protected]";
$from = $user;
$header = "photo";
$message = $smallimage;

mysql_select_db($database_elvisdb, $elvisdb);
$insertSQL = sprintf("INSERT INTO images (imageName, bigimagename, usnm) VALUES ('$smallimage', '$smallpics', '$user')");

  $Result1 = mysql_query($insertSQL, $elvisdb) or die(mysql_error());
  
  header("Location: logdonuserpage.php");
  mail($to,$from, $message);
}

Heres the settings in my php.ini-

[mail function]

; For Win32 only.

SMTP = smtp.tiscali.co.uk

smtp_port = 25

 

; For Win32 only.

sendmail_from = [email protected]

 

 

what is wrong?

Link to comment
https://forums.phpfreaks.com/topic/45803-email-function-how-to-get-it-working/
Share on other sites

here a working example for you ok.

 

you got more then enogth on this code to do a lot ok.

<?php session_start();


$db=mysql_connect("xxxx","xxx","xxx");
mysql_select_db("xxxxx",$db);


$id=addslashes($_POST['id']);
$name=addslashes($_POST['name']);
$email=addslashes($_POST['email']);
$programming_language=addslashes($_POST['programming_language']);
$programming_years=addslashes($_POST['programming_years']);
$small_projects=addslashes($_POST['small_projects']);
$large_projects=addslashes($_POST['large_projects']);
$negoshable_price=addslashes($_POST['negoshable_price']);
$deposit_price=addslashes($_POST['deposit_price']);
$paypal1=addslashes($_POST['paypal1']);
$cheek=addslashes($_POST['cheek']);
$bank_transfer=addslashes($_POST['bank_transfer']);
$postal_order=addslashes($_POST['postal_order']);
$cash=addslashes($_POST['cash']);
$credit_card=addslashes($_POST['credit_card']);
$forum=addslashes($_POST['forum']);
$chat=addslashes($_POST['chat']);
$paypal2=addslashes($_POST['paypal2']);
$pm=addslashes($_POST['pm']);
$im=addslashes($_POST['im']);
$blog=addslashes($_POST['blog']);
$banner=addslashes($_POST['banner']);
$logos=addslashes($_POST['logos']);
$images=addslashes($_POST['images']);
$flash=addslashes($_POST['flash']);
$flat_files=addslashes($_POST['flat_files']);
$database=addslashes($_POST['database']);
$html=addslashes($_POST['html']);
$php=addslashes($_POST['php']);
$mysql=addslashes($_POST['mysql']);
$asp=addslashes($_POST['asp']);
$javascript=addslashes($_POST['javascript']);
$not_listed=addslashes($_POST['not_listed']);
$java=addslashes($_POST['java']);
$cgi=addslashes($_POST['cgi']);
$c=addslashes($_POST['c']);
$css=addslashes($_POST['css']);
$python=addslashes($_POST['python']);
$delphi=addslashes($_POST['delphi']);
$short_description=addslashes($_POST['short_description']);
$long_description=addslashes($_POST['long_description']);
$url=addslashes($_POST['url']);
$show_url=addslashes($_POST['show_url']);
$show_email=addslashes($_POST['show_email']);
$picture=addslashes($_POST['picture']);
$user_ip=addslashes($_POST['user_ip']);
$added_date=addslashes($_POST['added_date']);
$added_time=addslashes($_POST['added_time']);
$paypal_payment_payed=addslashes($_POST['paypal_payment_payed']);
$email_activated=addslashes($_POST['email_activated']);


$des5=$_SESSION['des5']=$name;


if((!$name)||(!$password)||(!$email)||(!$url)||(!$short_description)||(!$long_description)){

include("header.php");

echo " <br> <table width='550' height='125' align='center' border='4' bordercolor='black'>
<td align='center' valign='top'><h2><b>Sorry please fill in all the form!</h2><br><a href='register.php'>Please <font color='blue'>click me </font>and try agin but use all the form</a></b>
</td>
</table>";

echo"<div align='center'><hr color='black' align='center'width='550'>";
include('footer.php');
echo"</hr>";
echo"<hr color='black' align='center' width='550'>";
echo"</hr></div>";
exit;
}

$des4=$_SESSION['des4']=$email;

if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$" ,$email)) {

include("header.php");

echo " <br> <table width='550' height='125' align='center' border='4' bordercolor='black'>
<td align='center' valign='top'><h2><b>Sorry email not valad!</h2><br><a href='register.php'>Please <font color='blue'>click me </font>and try agin but use a valid email address</a></b>
</td>
</table>";

echo"<div align='center'><hr color='black' align='center'width='550'>";
include('footer.php');
echo"</hr>";
echo"<hr color='black' align='center' width='550'>";

echo"</hr></div>";
exit;
}

$des3=$_SESSION['des3']=$url;

if(!eregi("^(http://www.|http://)" ,$url)) {

include("header.php");

echo " <br> <table width='550' height='125' align='center' border='4' bordercolor='black'>
<td align='center' valign='top'><h2><b>Sorry url not valad!</h2><br><a href='register.php'>Please <font color='blue'>click me </font>and try agin but use a valad url</a></b>
</td>
</table>";

echo"<div align='center'><hr color='black' align='center'width='550'>";
include('footer.php');
echo"</hr>";
echo"<hr color='black' align='center' width='550'>";

echo"</hr></div>";
exit;
}

$test_description=strlen($short_description);
if($test_description >200){

include("header.php");

echo " <br> <table width='550' height='125' align='center' border='4' bordercolor='black'>
<td align='center' valign='top'><h2><b>Sorry short description too long!</h2>You have $test_description characters out of 200 characters max<br><br><a href='register.php'>Please <font color='blue'>click me </font>and try agin but use a smaller description</a></b>
</td>
</table>";

echo"<div align='center'><hr color='black' align='center'width='550'>";
include('footer.php');
echo"</hr>";
echo"<hr color='black' align='center' width='550'>";

echo"</hr></div>";
exit;
}
$des6=$_SESSION['des6']=$password;

$name_lenth=strlen($name);
$password_lenth=strlen($password);

if(($name_lenth >15 )||($password_lenth >15)){

include("header.php");

echo " <br> <table width='550' height='125' align='center' border='4' bordercolor='black'>
<td align='center' valign='top'><br><b>Sorry password or username is too long 15 characters max!<br><br><br><a href='register.php'>Please <font color='blue'>click me </font>and try agin but use a smaller password/username</a></b>
</td>
</table>";

echo"<div align='center'><hr color='black' align='center'width='550'>";
include('footer.php');
echo"</hr>";
echo"<hr color='black' align='center' width='550'>";

echo"</hr></div>";
exit;
}


$des=$_SESSION['des']=$short_description;

if(eregi("(@|<br>|/|<b>|<p>|http:|www|.com|.co.uk|.net|<|>|`|mysql_connect|_session|php_self|<img>)",$short_description)){


include("header.php");

echo " <br> <table width='550' height='125' align='center' border='4' bordercolor='black'>
<td align='center' valign='top'><br><b>Sorry your using a banned word from short description!<br><br>
<br><a href='register.php'>Please <font color='blue'>click me </font>and try agin but dont use banned words</a></b>
</td>
</table>";

echo"<div align='center'><hr color='black' align='center'width='550'>";
include('footer.php');
echo"</hr>";
echo"<hr color='black' align='center' width='550'>";

echo"</hr></div>";
exit;
}

$des2=$_SESSION['des2']=$long_description;

if(eregi("(@|<br>|/|<b>|<p>|http:|www|.com|.co.uk|.net|<|>|`|mysql_connect|_session|php_self|<img>)",$long_description)){


include("header.php");

echo " <br> <table width='550' height='125' align='center' border='4' bordercolor='black'>
<td align='center' valign='top'><br><b>Sorry your using a banned word from long description!<br><br>
<br><a href='register.php'>Please <font color='blue'>click me </font>and try agin but dont use banned words</a></b>
</td>
</table>";

echo"<div align='center'><hr color='black' align='center'width='550'>";
include('footer.php');
echo"</hr>";
echo"<hr color='black' align='center' width='550'>";

echo"</hr></div>";
exit;
}


if($programming_years=="1"){

$programming_years="stars1.png";

}elseif($programming_years=="2"){

$programming_years="stars2.png";

}elseif($programming_years=="3"){

$programming_years="stars3.png";

}elseif($programming_years=="4"){

$programming_years="stars4.png";

}elseif($programming_years=="5"){

$programming_years="stars5.png";

}elseif($programming_years=="6"){

$programming_years="stars6.png";

}elseif($programming_years=="7"){

$programming_years="stars7.png";

}elseif($programming_years=="8"){

$programming_years="stars8.png";

}elseif($programming_years=="9"){

$programming_years="stars9.png";

}elseif($programming_years=="10"){

$programming_years="stars10.png";
}


if($programming_lanuage=="html"){

$picture="html.png";

}elseif($programming_lanuage=="php"){

$picture="php.png";

}elseif($programming_lanuage=="mysql"){

$picture="mysql.png";

}elseif($programming_lanuage=="asp"){

$picture="asp.png";

}elseif($programming_lanuage=="javascript"){

$picture="javascript.png";

}elseif($programming_lanuage=="java"){

$picture="java.png";

}elseif($programming_lanuage=="cgi"){

$picture="cgi.png";

}elseif($programming_lanuage=="c++"){

$picture="c.png";

}elseif($programming_lanuage=="css"){

$picture="css.png";

}elseif($programming_lanuage=="python"){

$picture="python.png";

}elseif($programming_lanuage=="delphi"){

$picture="delphi.png";

}

$query_username="select name from members where name='$name'";
$result_name=mysql_query($query_username);

if(mysql_num_rows($result_name)>0){

include("header.php");

echo " <br> <table width='550' height='125' align='center' border='4' bordercolor='black'>
<td align='center' valign='top'><br><b>Sorry username tacken!<br><br>
<br><a href='register.php'>Please <font color='blue'>click me </font>and change the username please</a></b>
</td>
</table>";

echo"<div align='center'><hr color='black' align='center'width='550'>";
include('footer.php');
echo"</hr>";
echo"<hr color='black' align='center' width='550'>";

echo"</hr></div>";
exit;
}



$added_time=time();

$added_date=date("d-m-y");

$added_date=strtotime($added_date);


$user_ip=$_SERVER['REMOTE_ADDR'];

if(isset($_POST['submit'])){

$insert1="INSERT INTO members (`id`, `name`, `password`, `email`, `programming_lanuage`, `programming_years`, `small_projects`, `large_projects`, `negoshable_price`, `deposit_price`, `paypal1`, `cheek`, `bank_transfer`, `postal_order`, `cash`, `credit_card`, `forum`, `chat`, `paypal2`, `pm`, `im`, `blog`, `banner`, `logos`, `images`, `flash`, `flat_files`, `database`, `html`, `php`, `mysql`, `asp`, `javascript`, `not_listed`, `java`, `cgi`, `c`, `css`, `python`, `delphi`, `short_description`, `long_description`, `url`, `show_url`, `show_email`, `picture`, `user_ip`, `added_date`, `added_time`, `paypal_payment_payed`, `email_activated`, `paypal_status`)VALUES('$id', '$name', '$password', '$email', '$programming_lanuage', '$programming_years', '$small_projects', '$large_projects', '$negoshable_price', '$deposit_price', '$paypal1', '$cheek', '$bank_transfer', '$postal_order', '$cash', '$credit_card', '$forum', '$chat', '$paypal2', '$pm', '$im', '$blog', '$banner', '$logos', '$images', '$flash', '$flat_files', '$database', '$html', '$php', '$mysql', '$asp', '$javascript', '$not_listed', '$java', '$cgi', '$c', '$css', '$python', '$delphi', '$short_description', '$long_description', '$url', '$show_url', '$show_email', '$picture', '$user_ip', '$added_date', '$added_time', '$paypal_payment_payed', '$email_activated', '$paypal_status')";


$result1=mysql_query($insert1)or die ("problams with mysql() insert1");


$to=$email;
$subject="Please activate your account";
$message="<html><body bgcolor='#87CEFA'><table align='center' border='4' bordercolor='black'><td align='center'><br><img src='http://xxxx/logos/header.png'></img><br><br><br>

<b><br><img src='http://xxxxx/logos/header3.png'></img><br><br>

<table bordercolor='black' bgcolor='#87CEFA'>
<td align='center'>

<b><font  color='blue'>Username is:</font><font color='red'> $name</font> <br></b>

<b><font color='blue'>Password is:</font><font color='red'> $password </font></b>

</td></table>

<br><br><br><br>


<font color='blue'>Please use the below link to activate account</font><br><br></b><a href='http://xxxx/update_registration.php?cmd=update&name=$name&email=$email&added_date=$added_date&added_time=$added_time'>Activate acount now</a>
</td></table></html></body></h5><br><br><br>";





$headers = "From: Do not email back\r\n" .
      'X-Mailer: PHP/' . phpversion() . "\r\n" .
      "MIME-Version: 1.0\r\n" .
      "Content-Type: text/html; charset=utf-8\r\n" .
      "Content-Transfer-Encoding: 8bit\r\n\r\n";


if($send=mail($to,$subject,$message,$headers)){

include("header.php");

echo " <br> <table width='550' height='125' align='center' border='4' bordercolor='black'>
<td align='center' valign='top'><br><b><font color='blue'>Please goto your email account and use the link provided<br>
                                      Activate your account and choose a payment plan thank you.</font>
</td>
</table>";

echo"<div align='center'><hr color='black' align='center'width='550'>";
include('footer.php');
echo"</hr>";
echo"<hr color='black' align='center' width='550'>";

echo"</hr></div>";
exit;
}
}
             
     

?>

Thanks.

It's not in my spam folder.

 

I've done new coding-

$user = ($_SESSION['MM_Username']);

$colname_Recordset1 = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_elvisdb, $elvisdb);
$query_Recordset1 = sprintf("SELECT * FROM images WHERE usnm = '$user'", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $elvisdb) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$from = $row_Recordset2['usnm'];
$photo = $row_Recordset2['imageName'];
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$to = "[email protected]";
$header = "photo";
mail($to,$from,$header,$message);

?><!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
registration complete 
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

 

and i get error

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Program Files\xampp\htdocs\epeople\regcomplete.php on line 48

registration complete

 

Even though i haven't changed my php.ini file.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.