Page 1 of 1

Sending a mail with attachment in PHP

Posted: Wed Nov 30, 2011 4:42 am
by daveshoope
I am trying to post a form to an email. I have a file field in the form which I want to send to the email as an attachment.

The attachment goes but the mail body is empty. I guess its because of the header "Content-type: " and Content -disposition, when I change the content type, the body displays but the attachment doesnt send anymore.

Please any help on how I can display my page body in text/html and still send my file as an attachment?
Thanks

Re: Sending a mail with attachment in PHP

Posted: Wed Nov 30, 2011 5:04 am
by twinedev
See my reply to this thread: viewtopic.php?f=1&t=130020&p=654007&hil ... er#p654007

phpMailer allows easy sending of attachments, and does all the work for you, there are lots of samples included with the download.

-Greg

Re: Sending a mail with attachment in PHP

Posted: Wed Nov 30, 2011 8:32 am
by daveshoope
Thanks twindev, I got the class, but I really havent figure out how to apply the class to solve my problem.
Imagine I have a form with just two fields, one is the message and the other is the file field, how do I use phpMailer to treat that form?

My code first uploads the file to the server and calls it into the attachment script. but the message will not show again... it just displays blank body.
Please I need more light on phpMailer use. Thanks in anticipation...

Re: Sending a mail with attachment in PHP

Posted: Wed Nov 30, 2011 5:02 pm
by twinedev
Well, without your code to see how you used the class, I would only be guessing at what may have been wrong. How did you code it compared to the example?

-Greg