Jump to content

Send Email


kjanceski

Recommended Posts

I have php script and I want to send Email but seems that the script doesn't work. I don't know where is the problem if you know please help.

Here is the code:

 

<?php
$conn=mysql_connect("localhost","root","");
mysql_select_db("forum",$conn);
$user=$_POST['user'];
$password=$_POST['password'];
$mail=$_POST['mail'];
$cry=crypt($password);
$sqlQuery="INSERT INTO user (user,password,mail,register) VALUES ('$user','$cry','$mail',0)";
mysql_query( $sqlQuery);
mail($mail,"Ebi se","Koj te ebat");
?> 

Link to comment
https://forums.phpfreaks.com/topic/55348-send-email/
Share on other sites

you could do with an container for teh query resource id ($var=mysql_query($sqlQuery);) but I don't think that is a problem...

 

where is the script running? is it local or on a server? if its local makes ure you have SMTP (in your php.ini file) set to your isp's mail server NOT localhost (unless you have a mail server on your machine that is).

Link to comment
https://forums.phpfreaks.com/topic/55348-send-email/#findComment-273563
Share on other sites

Please include information regarding whether you get any errors or not, so we don't have to execute the script ourselves :)

 

So if you get any errors please let us know and if you don't try this:

 


$sendmail = mail($to,$subject,$message);

if($sendmail) {
  echo "Mail sent succesfully!";
}
else {
  echo "Mail _not_ sent...";
}

 

It will let you check whether the mail was actually sent or if some error occurred....

Link to comment
https://forums.phpfreaks.com/topic/55348-send-email/#findComment-273564
Share on other sites

Where is the mail being sent? If it's to a Yahoo, AOL, or Hotmail address many people have reported problems with those services receiving PHP generated email messages.

 

You really should include a "From:" header in the 4th parameter to the mail() function:

<?php
$conn=mysql_connect("localhost","root","");
mysql_select_db("forum",$conn);
$user=$_POST['user'];
$password=$_POST['password'];
$mail=$_POST['mail'];
$from = "From: [email protected]\r\n";
$cry=crypt($password);
$sqlQuery="INSERT INTO user (user,password,mail,register) VALUES ('$user','$cry','$mail',0)";
mysql_query( $sqlQuery);
mail($mail,"Ebi se","Koj te ebat",$from);
?>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/55348-send-email/#findComment-273573
Share on other sites

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.