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
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
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
Share on other sites

Well it won't give you any error it will just return a success message on success and a failure message on failure. But if you get to see "Mail _not_ sent..." you know it is the mail() part of your script that doesn't work.

Link to comment
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: youremail@address.com.here\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
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.