<td valign="top" colspan="2"><p>Your message (required)</p> <textarea name="maildsc" required="required" cols="60" rows="10" >
<?php
</textarea> </td>
</tr>
<tr>
<td valign="top" colspan="2"><input type="submit" value="Submit" /></td>
</tr>
</table>
[/code]
The php code:
[php]<?php
//configs
$Host = “mailserverhostname”;
$Port = 2525;
$Username = $_POST[‘mailfrom’];
$Password = “thepassword”;
// processing start
if(isset($_POST['nmto'])){
$fromName = $_POST['nmfrom'];
$toName = $_POST['nmto'];
$mailAddressfrom = $_POST['mailfrom'];
$mailAddressto = $_POST['mailto'];
$subj = $_POST['mailsubj'];
$description = $_POST['maildsc'];
require_once(‘PHPMailer/class.phpmailer.php’);
//include(“class.smtp.php”); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
// $mail->Host = “mail.simvolleyball.com”; // SMTP server
// $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = $Host; // sets the SMTP server
$mail->Port = $Port; // set the SMTP port for the GMAIL server
$mail->Username = $Username; // SMTP account username
$mail->Password = $Password; // SMTP account password
$mail->AddAddress($mailAddressto, $toName);
$mail->SetFrom($mailAddressfrom, $fromName);
$mail->AddReplyTo($mailAddressfrom, $fromName);
$mail->Subject = $subj;
$mail->AltBody = $description; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML($description);
// $mail->AddAttachment(‘images/phpmailer.gif’); // attachment
// $mail->AddAttachment(‘images/phpmailer_mini.gif’); // attachment
$mail->Send();
//sending message to admin
$to = $mailAddressto;
$subject = $subj;
$body = $description;
//$headers = “From: [email protected]\r\n”.
// “Reply-To: [email protected]\r\n”;
// connect to your Inbox through port 143. See imap_open() function for more details
$mbox = imap_open("{".$Host.":143/notls}", $Username, $Password);
// save the sent email to your Sent folder by just passing a string composed
// of the entire message + headers. See imap_append() function for more details.
// Notice the ‘r’ format for the date function, which formats the date correctly for messaging.
imap_append($mbox, “{”.$Host.":143/notls}INBOX.Sent",
“From: {$mailAddressfrom}\r\n”.
“To: “.$to.”\r\n”.
“Subject: “.$subject.”\r\n”.
“Date: “.date(“r”, strtotime(“now”)).”\r\n”.
“\r\n”.
$body.
“\r\n”
);
// close mail connection.
imap_close($mbox);
echo “Message Sent
\n”;
echo ‘GO BACK 2’;
echo ‘GO BACK 3’;
} catch (phpmailerException $e) {
// echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
// echo $e->getMessage(); //Boring error messages from anything else!
}
}
?>[/php]