[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-user
Subject: Re: Commons Email 1.1 with Gmail and Provided Mail Session
From: myllokunmingia <myllokunmingia () gmail ! com>
Date: 2009-07-21 20:36:32
Message-ID: 24595368.post () talk ! nabble ! com
[Download RAW message or body]
Hi Siegfried,
We're using SMTP authentication when using the appserver session as desribed
here: http://java.sun.com/products/javamail/FAQ.html#gmail.
Thoughts?
Cheers,
Dan
Siegfried Goeschl wrote:
>
> Hi Dan,
>
> sorry for the long delay - can you have a look at
> https://issues.apache.org/jira/browse/EMAIL-70 - this issue was fixed
> for the upcoming commons-email-1.2 release.
>
> But I still don't understand your problem fully
>
> +) when using the appserver session are you using SMTP authentication?
>
> Cheers,
>
> SIegfried Goeschl
>
>
>
> myllokunmingia wrote:
> > Hi we're attempting to use a mail session provided by an application
> > server
> > with commons email 1.1 and the code below is the only way we could get
> > commons email to work with the gmail smtp server when providing a
> > session.
> > If a session is not provided commons email is able to send an email using
> > the gmail smtp server. Are we approaching the problem correctly? Or is
> > there
> > a way to incorporate the changes below into the code base?
> >
> > Thanks in advance,
> > Dan
> >
> > // set through server mail session cofiguration
> > // Properties props = new Properties();
> > //props.put("mail.smtps.auth", "true");
> > //props.put("mail.smtps.host", SMTP_HOST_NAME);
> > //props.put(Email.MAIL_TRANSPORT_PROTOCOL, "smtps");
> >
> > final Session session =
> > JndiUtil.lookup(Config.JNDI_MAIL_SESSION)
> >
> > SimpleEmail email = new SimpleEmail() {
> >
> > @Override
> > public void setMailSession(Session aSession) {
> > Class clazz = getClass();
> > try {
> > Field field = clazz.getField("session");
> > field.setAccessible(true);
> > field.set(this, session);
> > } catch (IllegalAccessException e) {
> > throw new ActionException(e);
> > } catch (IllegalArgumentException e) {
> > throw new ActionException(e);
> > } catch (NoSuchFieldException e) {
> > throw new ActionException(e);
> > } catch (SecurityException e) {
> > throw new ActionException(e);
> > }
> > }
> >
> > @Override
> > public Session getMailSession() throws EmailException {
> > return session;
> > }
> >
> > @Override
> > public String sendMimeMessage() throws EmailException {
> > Transport t = null;
> > try {
> > t = session.getTransport();
> > if (SMTP_AUTH_USER != null && SMTP_AUTH_PWD !=
> > null)
> > {
> > t.connect(SMTP_AUTH_USER, SMTP_AUTH_PWD);
> > } else {
> > t.connect();
> > }
> >
> > t.sendMessage(message,
> > message.getAllRecipients());
> > return message.getMessageID();
> > } catch (NoSuchProviderException e) {
> > throw new EmailException(e);
> > } catch (MessagingException e) {
> > throw new EmailException(e);
> > } finally {
> > if (t != null) {
> > try {
> > t.close();
> > } catch (MessagingException e) {
> > throw new EmailException(e);
> > }
> > }
> > }
> > }
> > };
> > email.setMsg(BODY);
> > email.addTo(TO);
> > email.setFrom(FROM);
> > email.setSubject(SUBJECT);
> > email.send();
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
>
--
View this message in context: \
http://www.nabble.com/Commons-Email-1.1-with-Gmail-and-Provided-Mail-Session-tp24390884p24595368.html
Sent from the Commons - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic