permaculture playing cards*
The moose likes Ant, Maven and Other Build Tools and the fly likes Not able to send mail in a Maven/Spring project (with otherwise working code) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Not able to send mail in a Maven/Spring project (with otherwise working code)" Watch "Not able to send mail in a Maven/Spring project (with otherwise working code)" New topic
Author

Not able to send mail in a Maven/Spring project (with otherwise working code)

Rohit Mehta
Ranch Hand

Joined: Mar 11, 2005
Posts: 79

Hi all, I am using java 6.0, Spring 3.0 & Maven. I am facing a strange problem.

I am trying to send mail from my application, but not able to do so. I checked with debug on, the logs seems fine - no exception/error but the mail doesn't trigger.



POM (relevant):




Logs:

DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.myorg.com", port 25, isSSL false
220 droutbound.logix.in ESMTP
DEBUG SMTP: connected to host "smtp.myorg.com", port: 25

EHLO ABCDE1234
250-droutbound.logix.in
250-8BITMIME
250-SIZE 26214400
250-STARTTLS
250-AUTH PLAIN LOGIN
250 AUTH=PLAIN LOGIN
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "SIZE", arg "26214400"
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP: Found extension "AUTH=PLAIN", arg "LOGIN"
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNl1cm25hbW2U6
c2NjYWRta1W5Ae3mVuc42Fy5Lmlu
334 UGFz7c63dv2cmQ6
WmVuc22Fy5MT7IzIw==
235 #2.0.0 OK Authenticated
DEBUG SMTP: use8bit false
MAIL FROM:<address@myorg.com> AUTH=address@myorg.com
250 sender <address@myorg.com> ok
RCPT TO:<address@myorg.com>
250 recipient <address@myorg.com> ok
DEBUG SMTP: Verified Addresses
DEBUG SMTP: address@myorg.com
DATA
354 go ahead

Body

.
250 ok: Message 325177010 accepted
QUIT
221 droutbound.logix.in


I have tried with other sample programs as well - with or without spring configurations. No error. BUT no mail as well.

IMP - same program(s) work fine if I use them in my other project which doesn't use maven - but otherwise have same configurations. In those logs there are some more lines in between ..

DATA
354 go ahead

From: address@myorg.com
To: address@myorg.com
Message-ID: <12694833.01327427956033.JavaMail.myid@ABCDE12345>
Subject: Say Hi ..
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Body
.


Have tried other samples from net as well, but no luck. Seems Maven is not OK with something. Any suggestions are welcome.


- Rohit
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

How are you running the program?


JBoss In Action
Rohit Mehta
Ranch Hand

Joined: Mar 11, 2005
Posts: 79

From different points - main() within class, outside class & through application logic flow. From everywhere - the logs are same (without those 4/5 lines as mentioned - otherwise smooth) - but no mail.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

If you'll notice, your message body on the failing email is ".".

Actually, that's a little suspicious, since you'd generally terminate an interactive email body with a single line with a "." on it, but I don't think that's supposed to apply here.

One thing that my be an issue, however, is that there are actually 2 jars required to send email. One is the jar with the javax.mail packages, the other is the activation.jar. It may be that activation.jar isn't getting pulled in.

Here's something that might help:

http://www.mkyong.com/maven/how-to-download-javamail-api-from-maven/


Customer surveys are for companies who didn't pay proper attention to begin with.
Rohit Mehta
Ranch Hand

Joined: Mar 11, 2005
Posts: 79

Thanks Tim for your reply. Actually it was not due to "not finding jar" but due to "over finding" of jars.

Don't know how, but somehow from other dependencies - these two (& other geronimo*) jars were pulling & these two were causing issue:

geronimo-activation_1.1_spec-1.0.1.jar
geronimo-javamail_1.4_spec-1.2.jar

I excluded them - & all is well.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

Actually, you should have gone the other direction. The javamail facility is a standard component of J2EE, if I'm not mistaken, so all the full-stack servers have it, though the partial implementations such as Tomcat and Jetty do not.

You can include the standard javamail API with scope "provided" and build a WAR that should then properly run in Geronimo using the Geronimo facilities.

If you need to be able to test under Tomcat, you can set up separate Tomcat and Geronimo profiles so that the appropriate references are made for the desired target server.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not able to send mail in a Maven/Spring project (with otherwise working code)