cainam29 Posted May 6, 2013 Share Posted May 6, 2013 (edited) need help, mail function not working...i would want to send an email after i generated the report and fill in the two textfield from the generated report here is my php mail code: <?php //for getting the variable in the URL $WirelessRemaining= $_GET['WirelessRemaining']; $WirelineRemaining = $_GET['WirelineRemaining']; $date1 = $_POST['date1']; $output= $_POST['output']; require 'include/DB_Open.php'; $to = "aaa.bbb@ccc.com"; $subject = "Test, $date1"; $body = "$output"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n"; $headers .= "From: aaa bbb <aaa.bbb@ccc.com>\r\n"; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } include 'include/DB_Close.php'; ?> this codes would have values coming from the generated report, which was performed by another php page $WirelessRemaining= $_GET['WirelessRemaining']; $WirelineRemaining = $_GET['WirelineRemaining']; while this is a date field from my main php page where the email button would be click to send mail $date1 = $_POST['date1']; and this is from the output of my report generator: $output= $_POST['output']; here is how i call the mail php page $("#Email").on('click',function() { var date1 = $('#Date').val(); var output = $('#report_sample.php').val(); $.post('mail.php',{date1:date1, output:output}, function(data){ $("#results").html(data); }); return false; }); Edited May 6, 2013 by cainam29 Quote Link to comment https://forums.phpfreaks.com/topic/277701-php-mail-function-not-working/ Share on other sites More sharing options...
jazzman1 Posted May 6, 2013 Share Posted May 6, 2013 What do you mean by saying - php mail function does not work? It doesn't work at all or in this particular example? Quote Link to comment https://forums.phpfreaks.com/topic/277701-php-mail-function-not-working/#findComment-1428597 Share on other sites More sharing options...
cainam29 Posted May 6, 2013 Author Share Posted May 6, 2013 im getting the message: Message successfully sent! but im not really getting the email...and i've already configured the php.ini for the smtp and port... Quote Link to comment https://forums.phpfreaks.com/topic/277701-php-mail-function-not-working/#findComment-1428625 Share on other sites More sharing options...
jazzman1 Posted May 6, 2013 Share Posted May 6, 2013 To send emails via SMTP ports you need to have a mail server, by default php uses sendmail. What OS are you using onto your machine? Quote Link to comment https://forums.phpfreaks.com/topic/277701-php-mail-function-not-working/#findComment-1428629 Share on other sites More sharing options...
cainam29 Posted May 6, 2013 Author Share Posted May 6, 2013 just windows xp... Quote Link to comment https://forums.phpfreaks.com/topic/277701-php-mail-function-not-working/#findComment-1428718 Share on other sites More sharing options...
jazzman1 Posted May 7, 2013 Share Posted May 7, 2013 Sorry, I am not a windows user. You can ask "google" (or someone here) whether XP provides a mail server by default. Quote Link to comment https://forums.phpfreaks.com/topic/277701-php-mail-function-not-working/#findComment-1428730 Share on other sites More sharing options...
cainam29 Posted May 7, 2013 Author Share Posted May 7, 2013 im using windows xp with a xampp installed and thats what im using... Quote Link to comment https://forums.phpfreaks.com/topic/277701-php-mail-function-not-working/#findComment-1428742 Share on other sites More sharing options...
DavidAM Posted May 7, 2013 Share Posted May 7, 2013 You did NOT supply the $headers variable to the mail function call. Unless you have the FROM address set correctly in the php.ini, the mail server probably refused to relay the message because the FROM address is not "valid" or is missing. I say refused, because the TRUE response from mail() simply means that PHP ran the function and handed the message to the appropriate agent. PHP does NOT know if the mail server rejects the message (in general). [You handed the envelope to the postman, you did not see the clerk at the office throw it in the floor because he does not like red-crayon-addressed letters] Remember, the FROM address needs to be one that has authority to send mail using the SMTP mail server you are accessing. For instance, if you use the SMTP server at AAA.com and use a from address of BBB.com, the mail server may decide the email is forged (it's not coming from someone@AAA.com) and refuse to relay it, or give it a high spam score. P.S. I have used mail from Linux for some very complex stuff. The first time I did it on a Windows 7 box running WAMP, I was surprised to see the message go with no real problem. I was fully expecting it to fail and was prepared to start searching for a sendmail() alternative, but thankfully that was not necessary. Quote Link to comment https://forums.phpfreaks.com/topic/277701-php-mail-function-not-working/#findComment-1428765 Share on other sites More sharing options...
cainam29 Posted May 7, 2013 Author Share Posted May 7, 2013 this is my header, and this is set up properly...i just changed it here for privacy... $headers .= "From: aaa bbb <aaa.bbb@ccc.com>\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/277701-php-mail-function-not-working/#findComment-1428786 Share on other sites More sharing options...
DavidAM Posted May 8, 2013 Share Posted May 8, 2013 (edited) I saw that. What i was saying was that you did not pass $headers to the mail() function $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n"; $headers .= "From: aaa bbb \r\n"; if (mail($to, $subject, $body)) { Edited May 8, 2013 by DavidAM Quote Link to comment https://forums.phpfreaks.com/topic/277701-php-mail-function-not-working/#findComment-1429019 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.