Re: Problem with attaching file (from a form) to email in PHP [message #172780 is a reply to message #172756] |
Tue, 01 March 2011 00:58 |
Cameleon
Messages: 7 Registered: February 2011
Karma:
|
Junior Member |
|
|
Thanks Jerry... can I use variables, like I did below... it keeps
telling me invalid address??
=======
// MAIL SUBJECT
$subject = $_POST['Sujet'] . " from site xyz";
$subject = str_replace("\'", "'", $subject);
// MAIL ADDRESSES
$nom = str_replace("'", "''", $_POST['Nom']);
$NameFrom = $nom;
$EmailFrom = "<" . $_POST['Email'] . ">";
$NameTo = "Test User";
$EmailTo = "<Tests(at)xyz(dot)com>";
.....
require_once '../class.phpmailer.php';
$mail = new PHPMailer(true);
try {
$mail->AddReplyTo($EmailFrom, $NameFrom);
$mail->AddAddress($EmailTo, $NameTo);
$mail->SetFrom($EmailFrom, $NameFrom);
$mail->AddReplyTo($EmailFrom, $NameFrom);
$mail->Subject = $subject;
$mail->AltBody = $message;
$mail->MsgHTML(file_get_contents('message.html'));
$mail->AddAttachment($UploadedFile_name);
$mail->Send();
echo "Message Sent OK<p></p>\n";
}
|
|
|