Hamish Posted May 21, 2007 Share Posted May 21, 2007 Hi All, I have the following email script which I can't get to work, please can anyone see where I am going wrong. Regards Hamish <?php //Check whether the submission is made if(isset($hidSubmit)){ //Declarate the necessary variables $mail_to=$txtEmailto; $mail_from=$txtEmailfrm; $mail_sub=$txtSub; $mail_mesg=$txtMsg; //Check for success/failure of delivery if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from/r/nReply-to:$mail_from")) echo "<span class='textred'>E-mail has been sent successfully from $mail_sub to $mail_to</span>"; else echo "<span class='textred'>Failed to send the E-mail from $mail_sub to $mail_to</span>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> <title>Untitled Document</title> </head> <body> <form name="frmsendmail" method="post" action="" onSubmit="return ValidationForm()"> <table width="100%" border="0"> <tr> <td width="33%" align="right" class="text">To : <td width="67%"><input name="txtEmailto2" type="text" class="input" id="txtEmailto22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">From : <td><input name="txtEmailfrm2" type="text" class="input" id="txtEmailfrm22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Subject : <td><input name="txtSub2" type="text" class="input" id="txtSub22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Mesage(body) : <td><textarea name="txtMsg" cols="50" rows="10" class="input" id="textarea"></textarea> </tr> <tr> <td align="right"><input name="hidSubmit" type="hidden" id="hidSubmit" value="true"> <input name="Submit" type="submit" class="input" value="Send"> <td><input name="Submit2" type="reset" class="input" value="Reset"> </tr> </table> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/52322-problem-with-simple-php-email-script/ Share on other sites More sharing options...
dream25 Posted May 21, 2007 Share Posted May 21, 2007 this script is wrong man.. i think u r copy this script from any tutorials.. am i right. i already checked this.. but its not working.. better search anyother... go for www.smartwebby.com Quote Link to comment https://forums.phpfreaks.com/topic/52322-problem-with-simple-php-email-script/#findComment-258181 Share on other sites More sharing options...
Hamish Posted May 21, 2007 Author Share Posted May 21, 2007 That's where I got the code, but there must be something not quite right. But I can't see it! Hamish Quote Link to comment https://forums.phpfreaks.com/topic/52322-problem-with-simple-php-email-script/#findComment-258234 Share on other sites More sharing options...
Hamish Posted May 21, 2007 Author Share Posted May 21, 2007 There must be a simple answer to it I, I thought it may have been a copy and paste problem so tried again, but it makes no difference, am still getting "failed to send message from" somebody must have hit this snag before. I would be grateful for any help. Regards Hamish Quote Link to comment https://forums.phpfreaks.com/topic/52322-problem-with-simple-php-email-script/#findComment-258275 Share on other sites More sharing options...
eagleweb Posted May 21, 2007 Share Posted May 21, 2007 See if this will work for you. There is no form field validation/error checking here. If you want to require fields, tell me which ones and I will add the code in. (The code is in the body instead) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> <title>Untitled Document</title> </head> <body> <?php //Check whether the submission is made if (!empty($_POST) { //Declarate the necessary variables $mail_to=$txtEmailto; $mail_from=$txtEmailfrm; $mail_sub=$txtSub; $mail_mesg=$txtMsg; mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from/are/nReply-to:$mail_from"); echo = "<p align=\"center\" class=\"textred\">E-mail has been sent successfully from $mail_sub to $mail_to</p>"; } else { ?> <form name="frmsendmail" method="post" action=""> <table width="100%" border="0"> <tr> <td width="33%" align="right" class="text">To : <td width="67%"><input name="txtEmailto2" type="text" class="input" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">From : <td><input name="txtEmailfrm2" type="text" class="input" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Subject : <td><input name="txtSub2" type="text" class="input" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Mesage(body) : <td><textarea name="txtMsg" cols="50" rows="10" class="input"></textarea> </tr> <tr> <td align="right"> <input name="Submit" type="submit" class="input" value="Send"> <td><input name="Submit2" type="reset" class="input" value="Reset"> </tr> </table> </form> }//end if !empty POST Quote Link to comment https://forums.phpfreaks.com/topic/52322-problem-with-simple-php-email-script/#findComment-258380 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.