2

I want to send email with php mail function, where I can also attach two pictures (.bmp , .gif, jpg , .png, .jpeg) only from the form without storing into any folder of website.
I tried many scripts but nothing is working correctly.
Can you tell me how to do it?

User1493
  • 481
  • 2
  • 7
  • 23
air
  • 6,136
  • 26
  • 93
  • 125

1 Answers1

1

You should not use the basic mail() function for that. Try one of the more featureful PHP classes for sending mails with attachments: PhpMailer vs. SwiftMailer?

  • Create mail object
  • Add image file as attachment.
  • Add content as HTML with image name as reference.

You need to concretise your problems when you have any. Nobody can help you with "but all is not working properly" unless you present some code and a detailed description.


If you want to do it tediously by hand, you can certainly use mail(). But it is more involving. Here are a few tutorials:

Please don't forget to show us your ready solution too if you really go that way.

Community
  • 1
  • 1
mario
  • 144,265
  • 20
  • 237
  • 291
  • Why should we not send with the native mail class ? – RobertPitt Feb 05 '11 at 16:33
  • @RobertPitt: There's nothing wrong with using the mail function. But it's significantly more effort to build up a multipart/ message "by hand". And since OP needs that, he should use a readymade solution. – mario Feb 05 '11 at 16:37
  • I thought you was saying the `mail` function itself was not very reliable when really its down to the OP To Build a stable header building class and use it to correctly handle multi-part data. – RobertPitt Feb 05 '11 at 16:59
  • Dear @mario i want to use mail function only, and i hope this question also help many others looking for same solution... – air Feb 05 '11 at 17:17
  • @air: Well you can do that. I've used following search http://www.google.com/search?hl=de&q=mail+php+generate+multipart%2Fmixed+images+body to find some solutions. See edit. – mario Feb 05 '11 at 17:48