Sending a mail with attachment in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
daveshoope
Forum Newbie
Posts: 8
Joined: Thu Aug 06, 2009 10:28 am

Sending a mail with attachment in PHP

Post 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
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Sending a mail with attachment in PHP

Post 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
daveshoope
Forum Newbie
Posts: 8
Joined: Thu Aug 06, 2009 10:28 am

Re: Sending a mail with attachment in PHP

Post 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...
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Sending a mail with attachment in PHP

Post 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
Post Reply