Gmunky Posted April 9, 2007 Share Posted April 9, 2007 I have a form page that has a subject,message, and from text box. I want to be able to send email once the submit button is clicked. my code: //if submit button is clicked, send email if (isset($_POST['submit'])) { $from=$_POST['from']; $message=$_POST['message']; $subject=$_POST['subject']; //$to=$_POST['to']; $to="[email protected]"; $date = date("F j, Y, g:i a"); $headers ="From: [email protected]"; if ( mail("$to","$subject","$message") ) { echo "<font color=red>Your message has been sent to $to. Thank You!</font><br>"; } else echo "mail not sent"; } The problem is I Keep getting this error below and I have no clue how to fix it! ErrorCode: 2 ErrorMsg : mail() [function.mail]: Unable to send message to SMTP server. No recipients specified. ite. ice ready. mail not sent Link to comment https://forums.phpfreaks.com/topic/46269-help-with-using-mail-to-send-a-simple-email/ Share on other sites More sharing options...
paul2463 Posted April 9, 2007 Share Posted April 9, 2007 try the following, change this line if ( mail("$to","$subject","$message") ) for this one if ( mail('$to','$subject','$message') ) notice the single comment marks around the variables not double ones which make them a string Link to comment https://forums.phpfreaks.com/topic/46269-help-with-using-mail-to-send-a-simple-email/#findComment-225051 Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 sorry off topic... just gotta say this.. paul2463, i love the WOW in yuor signature you cannot affect the past but you can ruin a perfectly good present by worrying about the future Link to comment https://forums.phpfreaks.com/topic/46269-help-with-using-mail-to-send-a-simple-email/#findComment-225053 Share on other sites More sharing options...
Gmunky Posted April 9, 2007 Author Share Posted April 9, 2007 thanks, but it didn't work. I still get the same error. Link to comment https://forums.phpfreaks.com/topic/46269-help-with-using-mail-to-send-a-simple-email/#findComment-225056 Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 have you tried $_REQUEST[] instead of $_POST? Link to comment https://forums.phpfreaks.com/topic/46269-help-with-using-mail-to-send-a-simple-email/#findComment-225057 Share on other sites More sharing options...
Gmunky Posted April 9, 2007 Author Share Posted April 9, 2007 I just tried it and it still doesn't work. I dont think that part of the code is the problem. Even if i hardcode the values and use mail("[email protected]","hello","This is a test"); i still get this error: ErrorCode: 2 ErrorMsg : mail() [function.mail]: Unable to send message to SMTP server. No recipients specified. ite. ice ready. mail not sent Link to comment https://forums.phpfreaks.com/topic/46269-help-with-using-mail-to-send-a-simple-email/#findComment-225066 Share on other sites More sharing options...
per1os Posted April 9, 2007 Share Posted April 9, 2007 http://us.php.net/manual/en/function.mail.php note this: Example 1050. Sending mail with extra headers. The addition of basic headers, telling the MUA the From and Reply-To addresses: <?php $to = '[email protected]'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> Example 1051. Sending mail with an additional command line parameter. The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path. <?php mail('[email protected]', 'the subject', 'the message', null, '[email protected]'); ?> Link to comment https://forums.phpfreaks.com/topic/46269-help-with-using-mail-to-send-a-simple-email/#findComment-225068 Share on other sites More sharing options...
Gmunky Posted April 9, 2007 Author Share Posted April 9, 2007 My error went away but I still don't get an email. I'm on an AS400/IBM platform Is there something I need to change in the .ini file? this is what mine looks like right now [mail function] SMTP = localhost smtp_port = 25 sendmail_from = [email protected] ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path = ; Force the addition of the specified parameters to be passed as extra parameter ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ;mail.force_extra_parameters = Link to comment https://forums.phpfreaks.com/topic/46269-help-with-using-mail-to-send-a-simple-email/#findComment-225111 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.