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

2009-12-31 Thread mnr ngsk
Thanks your quick response.
I didn't find that issue.


2009/12/31 minor-undroid mnrn...@gmail.com

 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 mnrn...@gmail.com 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=
 img(\[^\]*\|'[^']*'|
  [^'\])*src=(\[^\]*\|'[^']*'|[^'\])*/?;
 
  private MimeMessage mmHtmlMsg = null;
  private MimeMultipart   mmpHtmlMail = null;
  private String  strHtmlSrc = ;
  private boolean bAttach = false;
  private String  strAttach = ;
 
  private ArrayListReplacedImgTag replacedImgTagList
  = new
 ArrayListReplacedImgTag();
 
  // 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; wAttachment
  (mixed););
 
  AttachedMessageBodyFactory
 attachMbpFactory = new
  AttachedMessageBodyFactory();
 
 attachMbpFactory.setAttachment(this.strAttach);
  mbpAttach =
 attachMbpFactory.createMessageBody();
 
   

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

2009-12-24 Thread mnr ngsk
Hi Don,
Thanks for your reply.  and I send new Issue
Issue 2559: Support other headers on outbound email

BTW, could you tell me which headers of outbound email GAE support now ?


Thanks,


2009/12/23 Don Schwarz schwa...@google.com

 Unfortunately we only support a fixed set of headers on outbound email
 messages, and these headers are not currently supported.

 Please file a feature request in our issue tracker:

 http://code.google.com/p/googleappengine/issues/list

 On Tue, Dec 22, 2009 at 9:06 AM, minor-undroid mnrn...@gmail.com wrote:

 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 mnrn...@gmail.com 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.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.



  --
 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.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.


--

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.