05-04-2012, 06:18 PM
|
#8 (permalink)
|
|
Regular User
Join Date: May 2012
Posts: 16
|
Re: Php form mail script
Send mail from php using inbuilt function without smtp.
Example:
Quote:
// --------------------------------
// Function used to send PHP Email
// --------------------------------
/**
* Email function
* @param string $fromName
* @param string $fromEmail
* @param string $receiverEmail
* @param string $subject
* @param string $content
* @param string $replyName
* @param boolean $debug
* @return 1 or null
*/
function sendEmail($fromName, $fromEmail, $receiverEmail, $subject, $content, $replyTo="", $debug=false) {
$sendMail = new PHPMailer();
$sendMail->FromName = $fromName;
$sendMail->From = $fromEmail;
$sendMail->AddAddress($receiverEmail);
if(trim($replyTo)!="")
$sendMail->AddReplyTo($replyTo);
$sendMail->IsHtml(true);
$sendMail->Subject = $subject;
$sendMail->Body = html_entity_decode($content);
if($debug)
die(html_entity_decode($content));
else
return $sendMail->Send();
}
// ----------------------------------------
// Sending way using Form in one Page
// ----------------------------------------
<?php
if(isset($_POST['Submit']))
{
foreach($_POST as $key=>$val)
{ $$key=$val; }
/* $receiverRow = $funObj->configEmail();
$receiverEmail = $receiverRow['config_value'];*/
$receiverEmail = "info@example.com";/*Destination email address*/
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* additional headers */
$headers .= "From: $name <$email>\r\n";
//mail($receiverEmail, $subject, $message, $headers);
$mails = $funObj->sendEmail($name, $email, $receiverEmail, $subject, $message, "", false);
if($mails)
{
echo "Email is succesfully Delivered";
}
else
{
echo "<br/>Email is not Delivered";
}
}
?>
</center></font>
<form name="form3" method="post" action="">
<table width="450" border="0" cellpadding="5" cellspacing="5">
<tr>
<td colspan="2" align="left"><h2>Contact Form</h2> </td>
</tr>
<tr>
<td>Name</td>
<td>
<label>
<input type="text" name="name" id="name">
</label>
</td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" id="email"></td>
</tr>
<tr>
<td>Subject</td>
<td><input type="text" name="subject" id="subject"></td>
</tr>
<tr>
<td>Message</td>
<td>
<label>
<textarea name="message" id="message" rows="10" cols="40"></textarea>
</label>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<label>
<input type="submit" name="Submit" value="Submit">
</label>
</td>
</tr>
</table>
</form>
|
Last edited by fromfeed.com; 05-04-2012 at 06:21 PM.
Reason: some changes
|
|
|