View Full Version : Problem using PHP Mail form
Eduardo
11-02-2006, 07:14 AM
Hi,
recently I include in one of my sites a Email form en PHP Code, but the problem is when I try to run the emailform.php a windows appears with the code but not the form, and doesn´t works.
Please help me, I think the PHP code is not initalizated, please let me know how can I solve this problem.
Mi hosting server has a Linux OS and I am using Dreamweaver as mi pages Editor.
Thanks for your support, :eek:
Eduardo Cazares
codeexploiter
11-02-2006, 07:17 AM
can you provide the code for checking out that?
check you have PHP starting tag and closing tag in place.
Eduardo
11-02-2006, 07:25 AM
The code I was to use in my pages is yours, in a Post that I View you post a Demo with the form code an I try to use it, but doesn´t work in my page, I´m new in Web development but I want to solve this problem to go for the next code and learn.
The code is ...
<?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>";
}
?>
<form name="frmsendmail" method="post" action="" onSubmit="return ValidationForm()">
<table width="100%" border="0">
<tr>
<td width="33%" align="right" class="text">Para :
<td width="67%"><input name="txtEmailto2" type="text" class="input" id="txtEmailto22" size="30" maxlength="100">
</tr>
<tr>
<td align="right" class="text">De :
<td><input name="txtEmailfrm2" type="text" class="input" id="txtEmailfrm22" size="30" maxlength="100">
</tr>
<tr>
<td align="right" class="text">Titulo :
<td><input name="txtSub2" type="text" class="input" id="txtSub22" size="30" maxlength="100">
</tr>
<tr>
<td align="right" class="text">Descripción :
<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="Enviar">
<td><input name="Submit2" type="reset" class="input" value="Limpiar">
</tr>
</table>
</form>
Thanks
Eduardo Cazares
codeexploiter
11-02-2006, 07:35 AM
1. Check whether you've specified your SMTP server in php.ini file
2. Make sure that you've mentioned the correct port of your SMTP server in php.ini file
Plz check the attached image which is the one from the php.ini file where the SMTP server settings must be done.
Eduardo
11-02-2006, 08:02 AM
I try to use the code in a new window and when I put all the fields and try to send appears the next message ...
No recipient addresses found in header E-mail has been sent successfully from to
Maybe you cand see directly in your browser, the path is ...
http://www.quickadservers.com/formulario.php
Thanks for your support
Eduardo Cazares
codeexploiter
11-02-2006, 08:28 AM
<?php
//Check whether the submission is made
if(isset($_POST['hidSubmit']))
{
//Declarate the necessary variables
$mail_to = $_POST['txtEmailto'];
$mail_from = $_POST['txtEmailfrm'];
$mail_sub = $_POST['txtSub'];
$mail_mesg = $_POST['txtMsg'];
//specify your SMTP server name here; for ex i've mentioned mail.yoursmtpserver.com replace it with yours
ini_set("SMTP","mail.yoursmtpserver.com");
//Check for success/failure of delivery
if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from"))
echo "<span>E-mail has been sent successfully from $mail_sub to $mail_to</span>";
else
echo "<span>Failed to send the E-mail from $mail_sub to $mail_to</span>";
exit;
}
?>
<form name="frmsendmail" method="post" action="">
<table width="100%" border="0">
<tr>
<td width="33%" align="right">To :
<td width="67%"><input name="txtEmailto" type="text" size="30" maxlength="100">
</tr>
<tr>
<td align="right">From :
<td><input name="txtEmailfrm" type="text" size="30" maxlength="100">
</tr>
<tr>
<td align="right">Subject :
<td><input name="txtSub" type="text" size="30" maxlength="100">
</tr>
<tr>
<td align="right">Message :
<td><textarea name="txtMsg" cols="50" rows="10"></textarea>
</tr>
<tr>
<td align="right"><input name="hidSubmit" type="hidden" value="true">
<input name="Submit" type="submit"value="Send">
<td><input name="Submit2" type="reset" value="Reset">
</tr>
</table>
</form>
ini_set("SMTP","mail.yoursmtpserver.com");
Please specify your smtp server here if you haven't mentioned that in your php.ini file.
After that use the above code for sending mails
I think i've posted a coding without testing it sorry about that. This one i've tested using my mail server it is sending mail
Eduardo
11-02-2006, 11:08 PM
Thank you very much Codeexploit, the problem was in the smtp code, now I can work in on that,
regards,
Eduardo Cazares
chechu
11-04-2006, 11:12 AM
I have troubles with my code.
If I copy yours, but wish to send it directly to an email adress, how would you adapt it ?
//specify your SMTP server name here; for ex i've mentioned mail.yoursmtpserver.com replace it with yours
ini_set("SMTP","mail.yoursmtpserver.com");
chechu
11-09-2006, 03:26 PM
Any ideas ?
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.