You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Barry Kaplan <gr...@memelet.com> on 2011/04/07 16:46:14 UTC

Sending via smtp fails after some time

I am sending emails from a server. The emails get sent fine for some hours
(up to 24) but then I start getting exceptions that are ultimately:

  Caused by: javax.mail.AuthenticationFailedException: null

I am using the default javaMailSender and sending via gmail. The jvm is
started with Dmail.smtp.starttls.enable=true.

Any ideas what would cause gmail to accept the messages and then decide
later to reject the auth?

(camel 2.5.0)

thanks!


---- (the #'s are substituted by the scala compiler)
---------------------------------------------------
  private lazy val smtpUri =
"smtp://#{smtpHost}:#{smtpPort}?username=#{smtpUsername}&password=#{smtpPassword}"

      val msg = "Alert for device '#{device.name}'. #{alert.description}."
      log.info("Sending notification: to=#toEmail, msg=#msg") 
      val headers = Map[String,Object](
        "To" -> toEmail,
        "From" -> "support@vimana.us",
        "Subject" -> "Device Alert: #device.name - #alert.definition.name")
      producerTemplate.sendBodyAndHeaders(smtpUri, msg, headers.asJava)


--
View this message in context: http://camel.465427.n5.nabble.com/Sending-via-smtp-fails-after-some-time-tp4288728p4288728.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Sending via smtp fails after some time

Posted by Barry Kaplan <gr...@memelet.com>.
I'm only using one smtp endpoint. I also send email via logback via the same
smtp server with the same credentials and that never fails. I was looking at
how logback uses javamail vs spring and its quite different. Logback sets up
an authenticator with the transport, where passes the u/p with each connect.
Its amazing how (needlessly?) complex the javamail api is. I think if I
didn't have camel to send the emails I would just read the log file and send
paper mails via USPS ;-)

I'm upgrading to 2.7 now, but from what the camel code does I'm guessing the
issue is at the spring layer. But who knows. If I figure it out I'll of
course post it back here.

thanks Claus.

--
View this message in context: http://camel.465427.n5.nabble.com/Sending-via-smtp-fails-after-some-time-tp4288728p4291211.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Sending via smtp fails after some time

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

No idea. You can try upgrading the Java Mail API you use. However I
think some of the latest releases requires JDK6 now.

Also we fixed an issue when you had multiple smtp endpoints defined,
where camel-mail would use the default mail session.
In Camel 2.7 it always uses a new mail session instead. Maybe check
out the source code changes and backport that fix to 2.5 in case you
use multiple smtp endpoints.




On Thu, Apr 7, 2011 at 4:46 PM, Barry Kaplan <gr...@memelet.com> wrote:
> I am sending emails from a server. The emails get sent fine for some hours
> (up to 24) but then I start getting exceptions that are ultimately:
>
>  Caused by: javax.mail.AuthenticationFailedException: null
>
> I am using the default javaMailSender and sending via gmail. The jvm is
> started with Dmail.smtp.starttls.enable=true.
>
> Any ideas what would cause gmail to accept the messages and then decide
> later to reject the auth?
>
> (camel 2.5.0)
>
> thanks!
>
>
> ---- (the #'s are substituted by the scala compiler)
> ---------------------------------------------------
>  private lazy val smtpUri =
> "smtp://#{smtpHost}:#{smtpPort}?username=#{smtpUsername}&password=#{smtpPassword}"
>
>      val msg = "Alert for device '#{device.name}'. #{alert.description}."
>      log.info("Sending notification: to=#toEmail, msg=#msg")
>      val headers = Map[String,Object](
>        "To" -> toEmail,
>        "From" -> "support@vimana.us",
>        "Subject" -> "Device Alert: #device.name - #alert.definition.name")
>      producerTemplate.sendBodyAndHeaders(smtpUri, msg, headers.asJava)
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Sending-via-smtp-fails-after-some-time-tp4288728p4288728.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/