Click to See Complete Forum and Search --> : SMTP tag for attaching a file


Jacko123
July 9th, 2007, 06:46 AM
Hello,
I want to send an email via network. My requirement is to send an encrypted file via email.
I'm able to send plain text files but if I encrypt and send it, the encrypted file is received but I'm unable to open the file from my application. I get error "incorrect password" though I have entered the correct password.

what I did???
1) Using my application encrypted the file using AES::CBC mode (crypto++ lib) say with password "sample123"
2) Send this file by an attachment using this code to SMTP.

HELO there
MAIL FROM: <xyz@gmail.com>
RCPT TO: <abc@yahoo.com>
DATA
Content-Type: multipart/related; boundary=unique-boundary-1
--unique-boundary-1
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: binary
Content-Disposition: attachment; filename=samp.txt
MIME-Version: 1.0
From: <xyz@gmail.com>
To: <abc@yahoo.com>
Subject: samp.txt
//encrypted data.
.
QUIT

3) Received the file at abc@yahoo.com.
4) Open the file with the help of my application.
5) Fails to open as the file is modified. Get error as "incorrect password".

My questions:
1) Is the above data that I'm sending to SMTP correct??
2) How can I send an encrypted data over network so that the contents of the encrypted doesnt change...

Thanks in advance..

S_M_A
July 9th, 2007, 07:11 AM
Did you translate the encrypted data to plain text (ASCII for instance)?

Jacko123
July 9th, 2007, 07:20 AM
Did you translate the encrypted data to plain text (ASCII for instance)?
No I dont translate the encrypted data. Rather I want to send the encrypted data.
Once the encrypted file is sent, the Recipient detaches the file, load the file again in my application. Then he/she is asked to enter correct password with which the file was encrypted.

Thanks

S_M_A
July 9th, 2007, 09:50 AM
The reason I asked was if the encrypted data contains control characters I guess that they will not be received "as is".

henky@nok.co.id
July 10th, 2007, 02:23 AM
You can't send encrypted data as is. You must encode it into text file.
(Note: SMTP just allow text transmission). Most of mailers are using
base64 encoding to convert binary data into text. For more detail info,
please check MIME specification.

Henky