PHP Code:
<?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>
Code:
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
Bookmarks