kjanceski Posted June 12, 2007 Share Posted June 12, 2007 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 More sharing options...
ToonMariner Posted June 12, 2007 Share Posted June 12, 2007 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 More sharing options...
Wuhtzu Posted June 12, 2007 Share Posted June 12, 2007 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 More sharing options...
kjanceski Posted June 13, 2007 Author Share Posted June 13, 2007 The script is on server not on local machine. There is no error code after execution. I'll try the error code you sent. Link to comment https://forums.phpfreaks.com/topic/55348-send-email/#findComment-273565 Share on other sites More sharing options...
Wuhtzu Posted June 13, 2007 Share Posted June 13, 2007 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 https://forums.phpfreaks.com/topic/55348-send-email/#findComment-273569 Share on other sites More sharing options...
kjanceski Posted June 13, 2007 Author Share Posted June 13, 2007 I entered the error code check and the message was "Mail sent succesfully!". Link to comment https://forums.phpfreaks.com/topic/55348-send-email/#findComment-273572 Share on other sites More sharing options...
kenrbnsn Posted June 13, 2007 Share Posted June 13, 2007 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 More sharing options...
kjanceski Posted June 13, 2007 Author Share Posted June 13, 2007 Yes the mail i'm sending to is on yahoo. I've tried to gmail too. Also i've add $from but still no result ??? Link to comment https://forums.phpfreaks.com/topic/55348-send-email/#findComment-273580 Share on other sites More sharing options...
kenrbnsn Posted June 13, 2007 Share Posted June 13, 2007 Have you looked in the SPAM mailboxes to see if the mail is being trapped? Ken Link to comment https://forums.phpfreaks.com/topic/55348-send-email/#findComment-273641 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.