Ender22 Posted April 12, 2007 Share Posted April 12, 2007 Hey... This seems to be something incredibly easy, but I have tried the sample scripts from many sites and I cant get any of them to send an email from my php page. Heres the code im using. <?php $to = '[email protected]'; $subject = 'the subject'; $from = '[email protected]'; $message = 'hello'; if(mail($to, $subject, $message, "From: $from")) echo "Mail sent"; // this never gets called else echo "Mail send failure - message not sent"; // this error always happens ?> Is there some setting in php.ini file or something I need to change? Also im sure the emails are not being sent to my junk folder or anything else, I have checked... but the else (Mail send failure) statement is always executed so the emails are not sending at all. :-\ this should be easy... right??? any help is greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/46765-cant-send-simple-email-mail-function-always-fails/ Share on other sites More sharing options...
craygo Posted April 12, 2007 Share Posted April 12, 2007 try setting your headers $headers = "From: Myname <$from>\r\n"; $headers .= "BCC: $bcc\r\n"; //leave the next 2 lines alone $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; then use if(mail($to, $subject, $message, $headers)) Ray Link to comment https://forums.phpfreaks.com/topic/46765-cant-send-simple-email-mail-function-always-fails/#findComment-227910 Share on other sites More sharing options...
Glyde Posted April 12, 2007 Share Posted April 12, 2007 php.ini directives to check: SMTP sendmail_from Should be closer to the bottom of the file. You'll have to change those to the PHP host, and the default user to show as the from address. Link to comment https://forums.phpfreaks.com/topic/46765-cant-send-simple-email-mail-function-always-fails/#findComment-228010 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.