[appengine-java] Can I make GAE send an e-mail with Resent-To header ?

2009-12-18 Thread minor-undroid
I'd like to make an e-mail forward by GAE with Resent-To/Resent-From
header.

I tried the "client Java program with JavaMail" that I made,
and got the suitable result.
I applied ...
  mail.host:   smtp.gmail.com
  mail.smtp.auth:  true
  mail.smtp.socketFactory.port: 465
  mail.smtp.starttls.enable:true
  ...and more...

and Message Header is ...
  Resent-From ; xxxresentf...@aaa.com// my admin account
  Resent-To :   xxxresen...@bbb.com
  Resent-Date:  Mon, 30 Nov 2009 12:59:59 +  // Exactly now
  From: yyyf...@ccc,com
  To:   yy...@ddd.com
  Date: Sun, 01 Nov 2009 12:59:59 +  // Past date

so, the result was good (It was just what I had expected).
The response header is above.
  An e-mail looks like
-- comming from yyyf...@ccc,com.
-- comming at 01 Nov 2009.
-- going to yy...@ddd.com, but he(yy...@ddd.com) didn't get
   this e-mail, but another(xxxresen...@bbb.com) got this mail.


Then I tried that I implemented above code and a few fixed code,
and deployed on GAE, ran this application on GAE, but it left log
as warnings as follows.
  Failed: Send failure (javax.mail.MessagingException:
  Illegal Arguments (java.lang.IllegalArgumentException:
  Unauthorized Sender: Unauthorized sender))
or
  Failed: Unable to locate provider for protocol: smtp
or
  Failed: Illegal Arguments (java.lang.IllegalArgumentException:
  Bad Request: Missing recipients)


Does anyobody know a solution to this ?
What I want to do is to function Resent-To/Resent-From header
appropriately !


Thanks,

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: Can I make GAE send an e-mail with Resent-To header ?

2009-12-22 Thread minor-undroid
Hi, there

I'd like to forward an email message.
Please tell me any idea.


Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);

// From
message.addHeader("Resent-From", MYACCOUNT);// my
GAE account address
InternetAddress fromAddress = new InternetAddress(from);
message.setFrom(fromAddress);

// Sender
message.addHeader("Resent-Sender", MYACCOUNT);//
my GAE account address
message.addHeader("Sender", fromAddress.getAddress());

// To
message.addHeader("Resent-To",
resentTo);// I wanna forward this email at him
InternetAddress toList[] = InternetAddress.parse(to, false);
message.addRecipients(MimeMessage.RecipientType.TO, toList);//
TO address list including me

message.setSubject(subject);

message.setText(message);

Transport transport = session.getTransport();
transport.connect();
InternetAddress resentToList[] = InternetAddress.parse(resentTo,
false);
transport.sendMessage(message,
resentToList);// send to Resent-To address
transport.close();


Thanks,



On Dec 19, 2:11 am, minor-undroid  wrote:
> I'd like to make an e-mail forward by GAE withResent-To/Resent-From
> header.
>
> I tried the "client Java program with JavaMail" that I made,
> and got the suitable result.
> I applied ...
>   mail.host:       smtp.gmail.com
>   mail.smtp.auth:  true
>   mail.smtp.socketFactory.port: 465
>   mail.smtp.starttls.enable:    true
>   ...and more...
>
> and Message Header is ...
>  Resent-From ; xxxresentf...@aaa.com            // my admin account
>  Resent-To :   xxxresen...@bbb.com
>  Resent-Date:  Mon, 30 Nov 2009 12:59:59 +  // Exactly now
>   From:         yyyf...@ccc,com
>   To:           yy...@ddd.com
>   Date:         Sun, 01 Nov 2009 12:59:59 +  // Past date
>
> so, the result was good (It was just what I had expected).
> The response header is above.
>   An e-mail looks like
>     -- comming from yyyf...@ccc,com.
>     -- comming at 01 Nov 2009.
>     -- going to yy...@ddd.com, but he(yy...@ddd.com) didn't get
>        this e-mail, but another(xxxresen...@bbb.com) got this mail.
>
> Then I tried that I implemented above code and a few fixed code,
> and deployed on GAE, ran this application on GAE, but it left log
> as warnings as follows.
>   Failed: Send failure (javax.mail.MessagingException:
>           Illegal Arguments (java.lang.IllegalArgumentException:
>           Unauthorized Sender: Unauthorized sender))
> or
>   Failed: Unable to locate provider for protocol: smtp
> or
>   Failed: Illegal Arguments (java.lang.IllegalArgumentException:
>           Bad Request: Missing recipients)
>
> Does anyobody know a solution to this ?
> What I want to do is to functionResent-To/Resent-From header
> appropriately !
>
> Thanks,

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-12-31 Thread minor-undroid
Hi there,

I reproduced same problem.
I cannot send attachment file and inline image with HTML mail.
(Of course, I could send plain text mail without attachment and
 HTML mail without inline image)
I don't have any idea.  It would be very helpful to tell me anything.

I build the mime message in HtmlMimeMessage#createMimeMessage method.
My code is as follows,
/
*/
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

import javax.activation.DataHandler;
import javax.mail.MessagingException;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.util.ByteArrayDataSource;

import com.mnrngsk.test20091217.mail.CommonData;
import com.mnrngsk.test20091217.mail.DbgLog;


public class HtmlMimeMessage {

private static final String CID_DOMAIN  = 
"@xxx";
private static final String REGEX_IMGTAG= 
"])*src=(\"[^\"]*\"|'[^']*'|[^'\">])*/?>";

private MimeMessage mmHtmlMsg = null;
private MimeMultipart   mmpHtmlMail = null;
private String  strHtmlSrc = "";
private boolean bAttach = false;
private String  strAttach = "";

private ArrayList replacedImgTagList
= new 
ArrayList();


// constructor
public HtmlMimeMessage(MimeMessage msg, boolean bAttach) {
this.mmHtmlMsg = msg;
this.bAttach = bAttach;
}

public void setSource(String strSrc) {
this.strHtmlSrc = strSrc;
}

public void setAttachment(String strAttach) {
if (this.bAttach) {
this.strAttach = strAttach;
}
}


private void addInlineImageTo(MimeMultipart mmp) {
int iImgSrcCount = this.replacedImgTagList.size();
for (int i = 0; i < iImgSrcCount; i++) {
DbgLog.info("HtmlMimeMessage#addInlineImageTo; Inline 
Image #" +
Integer.toString(i));

ImageMessageBodyFactory imageMbpFactory = new
ImageMessageBodyFactory(this.replacedImgTagList.get(i));
MimeBodyPart mbpImg = 
imageMbpFactory.createMessageBody();
try {
mmp.addBodyPart(mbpImg);
DbgLog.info("HtmlMimeMessage#addInlineImageTo;\n
mbpImg#ContentType="
+ mbpImg.getContentType() + "\n 
 this.mmpHtmlMail#ContentType="
+ mmp.getContentType());
} catch (MessagingException e) {
e.printStackTrace();
DbgLog.warning("HtmlMimeMessage#addInlineImageTo;
MessagingException; " + e.getMessage());
}
}
}

public boolean createMimeMessage() {
boolean bRes = false;

try {
TextByHtmlMessageBodyFactory textMbpFactory = new
TextByHtmlMessageBodyFactory(this.strHtmlSrc);
MimeBodyPart mbpText = 
textMbpFactory.createMessageBody();

HtmlMessageBodyFactory htmlMbpFactory = new 
HtmlMessageBodyFactory
(this.strHtmlSrc, replacedImgTagList);
MimeBodyPart mbpHtml = 
htmlMbpFactory.createMessageBody();

MimeMultipart mmpMixed = null;
MimeBodyPart mbpAttach = null;

if (this.bAttach) {
DbgLog.info("HtmlMimeMessage#createMimeMessage; 
w Attachment
(mixed);");

AttachedMessageBodyFactory attachMbpFactory = 
new
AttachedMessageBodyFactory();
attachMbpFactory.setAttachment(this.strAttach);
mbpAttach = 
attachMbpFactory.createMessageBody();

mmpMixed = attachMbpFactory.getMultipart();
}

MimeMultipart mmpAlter = new 
MimeMultipart("alternative");

if (mbpText != null) {
mmpAlter.addBodyPart(mbpText);
DbgLog.info("HtmlMimeMessage#createMimeMessage;"
+ "\n  mbpText#ContentType=" + 
mbpText.getContentType()
+ "\n  mmpAlter#ContentType=" + 
mmpAlter.getContentType()
  

[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-12-31 Thread minor-undroid
Sorry, I made a wrting mistake.

I cannot send the HTML mail with inline image,
and cannot send the HTML mail with attachement file, too.
(I could send the plain text mail with an attachment image
 and HTML mail without attachment file)

I think It's only GAE's problem.
Do you have any idea?


On Dec 31, 11:23 pm, minor-undroid  wrote:
> Hi there,
>
> I reproduced same problem.
> I cannotsendattachmentfile and inline image with HTMLmail.
> (Of course, I couldsendplain textmailwithoutattachmentand
>  HTMLmailwithout inline image)
> I don't have any idea.  It would be very helpful to tell me anything.
>
> I build the mime message in HtmlMimeMessage#createMimeMessage method.
> My code is as follows,
> /
> */
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.util.ArrayList;
> import java.util.regex.Matcher;
> import java.util.regex.Pattern;
> import java.util.regex.PatternSyntaxException;
>
> import javax.activation.DataHandler;
> import javax.mail.MessagingException;
> import javax.mail.internet.MimeBodyPart;
> import javax.mail.internet.MimeMessage;
> import javax.mail.internet.MimeMultipart;
> import javax.mail.util.ByteArrayDataSource;
>
> import com.mnrngsk.test20091217.mail.CommonData;
> import com.mnrngsk.test20091217.mail.DbgLog;
>
> public class HtmlMimeMessage {
>
>         private static final String             CID_DOMAIN              = 
> "@xxx";
>         private static final String             REGEX_IMGTAG    = 
> " [^'\">])*src=(\"[^\"]*\"|'[^']*'|[^'\">])*/?>";
>
>         private MimeMessage                     mmHtmlMsg = null;
>         private MimeMultipart                   mmpHtmlMail = null;
>         private String                  strHtmlSrc = "";
>         private boolean                         bAttach = false;
>         private String                  strAttach = "";
>
>         private ArrayList replacedImgTagList
>                                                         = new 
> ArrayList();
>
>         // constructor
>         public HtmlMimeMessage(MimeMessage msg, boolean bAttach) {
>                 this.mmHtmlMsg = msg;
>                 this.bAttach = bAttach;
>         }
>
>         public void setSource(String strSrc) {
>                 this.strHtmlSrc = strSrc;
>         }
>
>         public void setAttachment(String strAttach) {
>                 if (this.bAttach) {
>                         this.strAttach = strAttach;
>                 }
>         }
>
>         private void addInlineImageTo(MimeMultipart mmp) {
>                 int iImgSrcCount = this.replacedImgTagList.size();
>                 for (int i = 0; i < iImgSrcCount; i++) {
>                         DbgLog.info("HtmlMimeMessage#addInlineImageTo; Inline 
> Image #" +
> Integer.toString(i));
>
>                         ImageMessageBodyFactory imageMbpFactory = new
> ImageMessageBodyFactory(this.replacedImgTagList.get(i));
>                         MimeBodyPart mbpImg = 
> imageMbpFactory.createMessageBody();
>                         try {
>                                 mmp.addBodyPart(mbpImg);
>                                 
> DbgLog.info("HtmlMimeMessage#addInlineImageTo;\n
> mbpImg#ContentType="
>                                                 + mbpImg.getContentType() + 
> "\n  this.mmpHtmlMail#ContentType="
>                                                 + mmp.getContentType());
>                         } catch (MessagingException e) {
>                                 e.printStackTrace();
>                         DbgLog.warning("HtmlMimeMessage#addInlineImageTo;
> MessagingException; " + e.getMessage());
>                         }
>                 }
>         }
>
>     public boolean createMimeMessage() {
>         boolean bRes = false;
>
>         try {
>                 TextByHtmlMessageBodyFactory textMbpFactory = new
> TextByHtmlMessageBodyFactory(this.strHtmlSrc);
>                         MimeBodyPart mbpText = 
> textMbpFactory.createMessageBody();
>
>                         HtmlMessageBodyFactory htmlMbpFactory = new 
> HtmlMessageBodyFactory
> (this.strHtmlSrc, replacedImgTagList);
>                         MimeBodyPart mbpHtml = 
> htmlMbpFactory.createMessageBody();
>
>                         MimeMultipart mmpMixed = null;
>