newbie8899 Posted January 12, 2008 Share Posted January 12, 2008 Hi, all.. i have a big problem here. I wish to send email through the php script.. but i don know what's wrong with it. it stated there email sent.. but i cannot receive any email. Can anybody tell me what probably did i do wrong? below is my test script which i use to test send the email. <?php //define the receiver of the email $to = '[email protected]'; //define the subject of the email $subject = 'Test email'; //define the message to be sent. Each line should be separated with \n $message = "Hello World!\n\nThis is my first mail."; //define the headers we want passed. Note that they are separated with \r\n $headers = "From: [email protected]\r\nReply-To: [email protected]"; //send the email $mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Mail sent" : "Mail failed"; ?> after i run the script, the browser showing Mail sent. but when i check my email account, i did not receive any of this email. :'( Link to comment https://forums.phpfreaks.com/topic/85640-how-to-send-email-through-php/ Share on other sites More sharing options...
phpSensei Posted January 12, 2008 Share Posted January 12, 2008 Check your Junk folder, most of the time it goes there if your headers are wrong, if I am not mistaking. Also, Try <?php //define the receiver of the email $to = '[email protected]'; //define the subject of the email $subject = 'Test email'; //define the message to be sent. Each line should be separated with \n $message = "Hello World!\n\nThis is my first mail."; //define the headers we want passed. Note that they are separated with \r\n $headers = "From: [email protected]\r\nReply-To: [email protected]"; //send the email $mail_sent = mail( $to, $subject, $message, $headers ); if($mail_sent){ echo 'Email Was Sent'; } else{ echo 'Email was not sent'; } ?> If/Else statement would make things much more simple. Link to comment https://forums.phpfreaks.com/topic/85640-how-to-send-email-through-php/#findComment-437054 Share on other sites More sharing options...
revraz Posted January 12, 2008 Share Posted January 12, 2008 Maybe hotmail is blocking it, try another email service. Remove the @ from mail as well to see if any errors return. Link to comment https://forums.phpfreaks.com/topic/85640-how-to-send-email-through-php/#findComment-437055 Share on other sites More sharing options...
PC Nerd Posted January 12, 2008 Share Posted January 12, 2008 I find that gmail allows any mail(); emails I send. try signing up for a free account there. good luck. Link to comment https://forums.phpfreaks.com/topic/85640-how-to-send-email-through-php/#findComment-437058 Share on other sites More sharing options...
newbie8899 Posted January 12, 2008 Author Share Posted January 12, 2008 I've tried all kind of email acc, but no 1 can be received.. is it possible that the problem of configuration in php.ini? i totally have no idea.. even though i already remove the @ for mail, but still no error msg Link to comment https://forums.phpfreaks.com/topic/85640-how-to-send-email-through-php/#findComment-437062 Share on other sites More sharing options...
phpSensei Posted January 12, 2008 Share Posted January 12, 2008 I've tried all kind of email acc, but no 1 can be received.. is it possible that the problem of configuration in php.ini? i totally have no idea.. even though i already remove the @ for mail, but still no error msg Try phpinfo(); and look for SMTP, and see if its supported. Link to comment https://forums.phpfreaks.com/topic/85640-how-to-send-email-through-php/#findComment-437064 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.