To do the attachments in-game simply make a protocol for sending length-defined strings as part of the e-mail message. This would even allow having multiple attachments. Here is an example of what an entire e-mail transmission might look like
--EMAIL
To: user01@mail.24.cc
From: user02@mail.24.cc
Subject: A letter
Here is that letter i promised you
--ATTACHMENT
Filename: letter01.txt
Length: 44
Dear sir,
have a nice day
sincerely,
user02
Here the to and from addresses are the
account-name@mail.
mail-server-id.cc where mail-server-id is the numerical id of the mail server computer from os.getComputerId()
Attachments are marked by the
–ATTACHMENT line and you include the exact length of the contents of the attachment, including CR/LF before the body. By reading that exact number of characters you have the attachments contents. Using this you can define multiple attachments in succession. The only thing that is missing from the example is a way to ensure no-one can mess up the parsing of the message by including the key words in the e-mail addresses, subject, or message body. The attachments do not pose this threat since you have the length identifier to use for parsing them. To prevent e-mail addresses from causing a problem you can simply make having any character other than a-z, 0-9, dash, (-) and underscore (_) not allowed and then block anyone from using
–ATTACHMENT as an email address or have the parser know it cant be an attachment sincce you havent gotten to the body yet. For the subject and body you could replace certain characters like the dash (-) and colon ( : ) with html codes. Thus if you had a message like this
--EMAIL
To: user01@mail.24.cc
From: user02@mail.24.cc
Subject: A letter
Dear sir:
Here is that letter i promised you
--ATTACHMENT
Filename: letter01.txt
Length: 44
Dear sir,
have a nice day
sincerely,
user02
It could be transmitted like this
--EMAIL
To: user01@mail.24.cc
From: user02@mail.24.cc
Subject: A letter
Dear sir:
Here is that letter i promised you
--ATTACHMENT
Filename: letter01.txt
Length: 44
Dear sir,
have a nice day
sincerely,
user02
By replacing colons and dashes with the html code the person cant accidentally or intentionally mess with the parsing of the keywords for each section as the decoding of the html codes back into their origional characters would be done after you seperated the message into its parts. Again you would only do this replacing in the subject and body while e-mail addresses would simply make the keywords illegal and the attachments would be covered by the use of the sent length.