Sendmail with attached file

Just starting out? Need help? Post your questions and find answers here.
Cantor
New User
New User
Posts: 8
Joined: Fri May 09, 2003 10:34 pm

Sendmail with attached file

Post by Cantor »

Hi!

Is there a possibilty to use the sendmail-procedure (resources site) to send a mail with an attached file? The sendmail procedure only sends the message subject and the message body.

--
Greetings, Martin.
Mr Skunk
User
User
Posts: 12
Joined: Wed May 07, 2003 3:40 pm

Post by Mr Skunk »

Yes, you can use the Base64Encoder() function to add everything to your mails bodies. Attachements are just Base64 (or other) encoded files directely included as ascii in your mail body.

You will also need to use the multipart/mixed content type, and Boundary to build your mail.
Any mailler can show you the source of a mail, look at a source with an attachment to really see how to use multipart/mixed content type and Boundary (not very complicated).
ShDancer
User
User
Posts: 51
Joined: Sat Apr 26, 2003 5:49 am

Post by ShDancer »

Another thing.

Its true that i can use Base64 to encode, but how can i read an encoded mail with an attatchment?

Thanks...
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

@ShDancer:

Have a look here:
viewtopic.php?t=4970&highlight=base64decoder

Timo
quidquid Latine dictum sit altum videtur
ShDancer
User
User
Posts: 51
Joined: Sat Apr 26, 2003 5:49 am

Post by ShDancer »

freak wrote:@ShDancer:

Have a look here:
viewtopic.php?t=4970&highlight=base64decoder

Timo
Doh, i've seen it allready and forgot about it :oops:

Thanks.
Cantor
New User
New User
Posts: 8
Joined: Fri May 09, 2003 10:34 pm

Post by Cantor »

Mr Skunk wrote:Yes, you can use the Base64Encoder() function to add everything to your mails bodies. Attachements are just Base64 (or other) encoded files directely included as ascii in your mail body.
Thank You For Your answer.
Can You perhaps give an example how to code this? It's difficult for me to understand how the Base64Encoder() works with files.

--
Greetings,
Martin.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Sendmail with attached file

Post by PB »

I saw a lot of conflicting stories about sending mail with attachments, so in
the end I just downloaded "Blat" (a command line mailer) and included it in
my app as a binary. I can then send mail using the RunProgram command.
You can download it from here:

http://www.interlog.com/~tcharron/blat.html

It is totally legal to use Blat in your own apps this way as it has been placed
in the Public Domain and its own docs state (in part): "you can use it free
of charge for any purpose you like [...] You have permission to modify,
redistribute, hoard, or even sell Blat in its executable or source form [...]"

Just remember to compress its exe before IncludeBinary'ing it into your app,
to keep the inclusion small. (It's not that large, anyway). Also, it's a good
idea to rename it from Blat.exe to YourApp.exe so that any firewalls will
refer to it by your app's name, so that your users don't panic and wonder
why an app called "Blat.exe" is trying to access the Internet. :)

Maybe one day someone will post some good (working) sendmail code to
these forums, that supports attachments, so Blat doesn't have to be used.
Post Reply