kney Posted August 11, 2011 Share Posted August 11, 2011 Why doesn't this send the mail? if (isset($_POST['sendMail'])){ $to = "kenneth.dehouwer@devoteam.be"; $subject = "TEST email"; $message = " <html> <head> <title>HTML email</title> </head> <body> <p>This email contains HTML Tags!</p> <table> <tr> <th>Firstname</th> <th>Lastname</th> </tr> <tr> <td>John</td> <td>Doe</td> </tr> </table> </body> </html> "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; // More headers $headers .= 'From: <webmaster@felnet.be>' . "\r\n"; $headers .= 'Cc: myboss@example.com' . "\r\n"; mail($to,$subject,$message,$headers); } Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/ Share on other sites More sharing options...
AyKay47 Posted August 11, 2011 Share Posted August 11, 2011 you are using a sendmail() function, is this a custom function? what you want is the mail function Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255857 Share on other sites More sharing options...
kney Posted August 11, 2011 Author Share Posted August 11, 2011 sorry that was my old code, I use the mail function... Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255858 Share on other sites More sharing options...
AyKay47 Posted August 11, 2011 Share Posted August 11, 2011 nothing stands out to me as being incorrect, if the mail function is not working, it will be sending errors to your error.log, do you have error_reporting set to E_ALL? if so, what errors are you receiving..? Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255860 Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 sorry that was my old code, I use the mail function... what good is the old code to us? post the new one, maybe you changed something else and don't remember? Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255861 Share on other sites More sharing options...
PFMaBiSmAd Posted August 11, 2011 Share Posted August 11, 2011 Has any code you have tried worked? Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255862 Share on other sites More sharing options...
kney Posted August 11, 2011 Author Share Posted August 11, 2011 @WebStyles: The code above is the one I have now. @PFMaBiSmAd: None of the code ever worked. @AyKay47: Where can I configure the error logging? Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255863 Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 the code above does work. check the following: 1. emails are in your spam folder 2. you typed the wrong email address 1. either you have a smtp problem Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255867 Share on other sites More sharing options...
AyKay47 Posted August 11, 2011 Share Posted August 11, 2011 @WebStyles: The code above is the one I have now. @PFMaBiSmAd: None of the code ever worked. @AyKay47: Where can I configure the error logging? add theses lines to the top of your script, this will print any errors you are receving directly onto your webpage ini_set("error_reporting",E_ALL); ini_set("display_errors","ON"); Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255868 Share on other sites More sharing options...
kney Posted August 11, 2011 Author Share Posted August 11, 2011 I checked my spam folders, nothing's there. I also tried with 3 different email addresses and checked them if they were correct. The php.ini file has this configured: SMTP = localhost smtp_port = 25 mail.add_x_header = On mail.log = C:\ Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255870 Share on other sites More sharing options...
AyKay47 Posted August 11, 2011 Share Posted August 11, 2011 after you have done what i suggested answer this, are you on a localhost or a live host? Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255873 Share on other sites More sharing options...
kney Posted August 11, 2011 Author Share Posted August 11, 2011 I added the lines and it does not give me any errors. I'm working on a localhost Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255874 Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 you set smtp = localhost, so I assume you have an smtp server running on your machine? Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255875 Share on other sites More sharing options...
kney Posted August 11, 2011 Author Share Posted August 11, 2011 The page where I got the mail function from didn't say anything about a smtp server, only that i should put localhost after smtp Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255877 Share on other sites More sharing options...
PFMaBiSmAd Posted August 11, 2011 Share Posted August 11, 2011 Are you sure your $_POST['sendMail'] variable is set to that your code is even calling the mail() function? At a minimum, you should have error checking logic in your code to test the value mail() returns and display a success or failure message so that you know the result of calling the mail function. Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1255879 Share on other sites More sharing options...
kney Posted August 12, 2011 Author Share Posted August 12, 2011 This is the error i'm getting.. Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in \web\RecordDrivers\IndexRecord.php on line 322 Notice: Use of undefined constant mail - assumed 'mail' in \web\RecordDrivers\IndexRecord.php on line 323 Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1256245 Share on other sites More sharing options...
AyKay47 Posted August 12, 2011 Share Posted August 12, 2011 seems like you do not have an SMTP server set up on your localhost, in my opinion, i never encourage tampering with sending mail until your webpage is on a live server.. the host will provide the mail server for you.. however there are also third party mail servers out there Quote Link to comment https://forums.phpfreaks.com/topic/244504-php-mail-function/#findComment-1256311 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.