Code: Select all
<!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-1" />
<title>PHP Mailer</title>
</head>
<body>
<form method="post" action="send_email.php">
Email: <br />
<input name="email" id="email" type="text" /><br />
Subject:<br />
<input type="text" name="sub" id="sub"><br />
Message:<br />
<textarea name="message" id="message" rows="15" cols="40"></textarea><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
phpcode:
<html>
<head>
<title>PHPMailer</title>
</head>
<body>
<?php
$email=$_POST['email'];
$sub=$_POST['sub'];
$message=$_POST['message'];
echo $email;
echo $sub;
echo $message;
echo "<br />";
//error_reporting(E_ALL);
error_reporting(E_STRICT);
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
/*$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: Sachin Malmanchi<mail.siddharthatech.com>\r\n";
$headers .= "Subject: Test mail\r\n";
$headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";
$message = "This is a MIME encoded message.";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/plain;charset=utf-8\r\n\r\n";
$message .= "This is the text/plain version.";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/html;charset=utf-8\r\n\r\n";
$message .= "This is the <b>text/html</b> version.";
$message .= "\r\n\r\n--" . $boundary . "--";*/
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.siddharthatech.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
//$mail->SMTPSecure = "ssl"; // 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "host"; // sets the SMTP server
$mail->Port = 25; // set the SMTP port for the server
$mail->Username = "username"; // SMTP account username
$mail->Password = "password"; // SMTP account password
$mail->IsHTML(true);
$mail->SetFrom('email', 'Sachin malmanchi');
/*$mail->From = $email;
$mail->to = $email;*/
$mail->AddReplyTo("email","Sachin malmanchi");
//$mail->Subject = "Email send from siddharthatech.com";
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
/*$body = "Welcome";
$body .="Hiiiiiiiiiiii";
*/
$html = '<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Sachin</td><td>10th</td><td>April</td><td>1988</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
/*$message = "Multipart Message coming up" . "\r\n\r\n".
"--".$boundary.
"Content-Type: text/plain; charset=\"iso-8859-1\"" .
"Content-Transfer-Encoding: 7bit".
$text.
"--".$boundary.
"Content-Type: text/html; charset=\"iso-8859-1\"".
"Content-Transfer-Encoding: 7bit".
$html.
"--".$boundary."--";*/
$mail->MsgHTML($body);
$mail->MsgHTML($html);
$mail->Body = $message;
$mail->Subject = $sub;
$mail->To = $email;
$mail->From = $email;
$mail->Body = $message;
$mail->AddAddress("email", "Sachin malmanchi");
$mail->AddAttachment("attachments/mail.php");
$mail->AddAttachment("attachments/mail.rar");
$mail->AddAttachment("attachments/email.php");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent to!".$mail->AddAddress;
}
var_dump( $mail->send() );
?>
</body>
</html>what ever we enter in to the to field in the html form the mail will sent to that mail id