dcsimg
Using JavaMail as proxy, trouble passing attachments
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Edward_Maybert
Posted On:   Tuesday, November 16, 2004 09:47 AM

I am writing a POP3 email proxy server using JavaMail and am having trouble passing email attachments fetched from a remote server back to the local client. The attachments show up as encoded text in the body of the email rather then as attachments. Here is the code-snipped I am using: Socket localClientSocket; //Socket local mail program is using ( e.g. Outlook Express) MimeMessage msg; //Message from POP3 server // Assume Socket instantiated/connected to ok // and I sucessfully read remote message // ( "msg" is instantiated and valid ) ... // Pass message back to local client try{ msg.writeTo( localClientSocket.getOutputStream());    More>>

I am writing a POP3 email proxy server using JavaMail and am having trouble passing email attachments fetched from a remote server back to the local client. The attachments show up as encoded text in the body of the email rather then as attachments.


Here is the code-snipped I am using:

			
Socket localClientSocket; //Socket local mail program is using ( e.g. Outlook Express)
MimeMessage msg; //Message from POP3 server

// Assume Socket instantiated/connected to ok
// and I sucessfully read remote message
// ( "msg" is instantiated and valid )
...

// Pass message back to local client
try{
msg.writeTo( localClientSocket.getOutputStream());
}catch(Exception e){
System.out.println(e);
}



Any ideas of what I'm doing wrong? I'm thinking it a stream problem.


Any help would be greatly appreciated.


~ed

   <<Less

Re: Using JavaMail as proxy, trouble passing attachments

Posted By:   Edward_Maybert  
Posted On:   Tuesday, November 16, 2004 10:11 AM

I forgot to mention, since I am responding to the emails clients' "RETR" pop command, I am pre-ceeding the code segment with:


outToLocalClient = new OutputStreamWriter( localClientSocket.getOutputStream());

String customResponse = "+OK " + msg.getSize() + " octets" + "
";

outToLocalClient.write(customResponse);
outToLocalClient.flush();

About | Sitemap | Contact