FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Problem with attaching file (from a form) to email in PHP
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Problem with attaching file (from a form) to email in PHP [message #172781 is a reply to message #172780] Tue, 01 March 2011 01:07 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 2/28/2011 7:58 PM, Cameleon wrote:
> 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";
> }
>

Among other things, you need to do a LOT more sanitizing of your $_POST
fields. NEVER trust input from the user!

And look at the examples again. You do not place <..> around the address.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: SOCIAL NETWORK FOR PHP PLATFORM..
Next Topic: HTML select field where the OPTION text is of different colors
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 20:03:13 GMT 2024

Total time taken to generate the page: 0.04393 seconds