I tried searching the best keywords before posting here. I apologize if I am asking something that is obvious. I am aware of the fact that it is possible to send emails to the SMTP server using the arduino ethernet shield. I want to send picture attachments along with the mail. I am aware of the fact that it is possible to send attachments with some encoding inside the mail server. I would like to know whether there is any documentation of this being done using the arduino? I would be happy if some links are shared.

You can do the math. A 50,000 byte file is 400,000 bits. A 115200 baud rate means that 115200 bits per second get sent. Of those, 8 out of 10 are payload. 400,000 bits/8 = 50,000 packets. 11,500 packets per second will require about 5 seconds to send.

Your baud rate may be different, so the file might take longer to transfer.

The more important question is where in the Arduino's 2KB of SRAM are you planning on storing a 50KB picture?

Where is/are the picture(s) coming from? Getting the data from the SD card will take time. The data will not be being sent while it is being read. So, you need to add the time needed to read the data from the card to the time needed to send the data to get the total time required to read and send a picture.

I don't know of any Arduino code to do it, but the first thing you'll need to find is an encoder to take whatever format the picture is in, ensure it turns up as a JPEG, PNG, or other file format, then encode that file for transmission by email. A common encoding mechanism is Base 64.

You could trawl through that one and try to interpret it yourself. Alternately you could send an email with an image attachment using your normal mail client and packet-sniff the exchange with the non-SSL mail server. Being able to replay that message would be an ideal starting point. You can "cheat" and simply take the encoded image data, store that on the SD Card, and write your code to assemble the SMTP message using the pre-encoded image. The next step would be writing the code to take the original image and end up with the encoded version.

Write a function that will take a given Base 64 encoded file and wrap it with the appropriate SMTP & MIME leaders/trailers (i.e.: 'your' side of the SMTP conversation) as a script in a third file

Now simply play the script to the SMTP server, replacing "hello world" with the content of your script

Finally, write a function to take a given file on the SD card and convert it to Base 64 in a second file, reading a chunk, converting it and writing that chunk to the SD card (you'll want to do this in the smallest sized chunks you possibly can)

This will not handle errors gracefully, but handling SMTP errors gracefully is usually a matter of disconnecting and forgetting the transaction ]

I guesstimate that a brain-dead implementation of the above will take somewhere in the order of a minute to send a 10kB image, most of which will be transferring data back and forth between the Arduino and the SD Card. A smarter implementation which can generate the SMTP conversation and do Base64 encoding on the fly should manage to send the entire message in a few seconds (limited by how fast you can read the data off the SD Card).

But baby steps. Remember Knuth:

First, make it work

Then, make it work right

Only then, make it work fast

In my brief flirtation with Bing and Google just now, I couldn't find any pointers to a Base64 library for Arduino. If anyone can find one, please mention it in this thread, 'cos I want to do Base64 encoding too

If no such beast exists, that will probably be my homework for the weekend.

Sending photo attachments is not a good task for the Arduino. The ATmega328 is a microcontroller not a microprocessor. Encoding, attaching, and sending a 50kb file through the poor little ATmega328 probably isn't worth the trouble. There are a lot of limitations you'll have to solve with very creative solutions.

Now, if you are trying to do this under the category of "Let's see if it can be done" that is a different story. If you are trying to accomplish any other goal (like build a system of automated webcams) the Arduino isn't a good choice.

My main objective is to transfer pictures from the JPEG cam that I posted above and I wanted to do it via ethernet shield/ arduino black widow shield. I am looking into best methods to do this.

Now that I posted here, I am able to gauge the possibilities before I hit a dead end. From what I read, the camera that I posted in my previous thread generates images from 3KB to 9KB. I do not want my arduino to be tethered to a computer via USB.

Sending photo attachments is not a good task for the Arduino. The ATmega328 is a microcontroller not a microprocessor. Encoding, attaching, and sending a 50kb file through the poor little ATmega328 probably isn't worth the trouble. There are a lot of limitations you'll have to solve with very creative solutions.

Pardon? What is the trouble? What limitations?

This would be how to base64 encode & send to the SMTP server a file named picture from a SD:

Interesting problem. Obviously, the hardest part is to build the SMTP client state machine that implements something like section 4.2 in RFC 3030 (see link in reply by ManicDee). Assuming your SMTP server supports chunking, then all you have to do is the following:

1) Get the binary data of the image file as a stream of octets (bytes)2) Invoke the state machine and follow the protocol (plus whatever cleartext auth needed) up until the BDAT part3) Issue a BDAT for the size of the binary data (or send them in chunks)4) Blast the binary data across the wire.5) Issue a BDAT 0 LAST6) Wait for confirmation of all data chunks, issue QUIT and close the connection.

You should be able to find C-based SMTP client code in the open-source realm and adapt it for the Arduino. In any case, sounds like quite a bit of work. Also, I would imagine it would be very, very hard to build an SSL stack on the Arduino.