aspose file tools*
The moose likes Spring and the fly likes spring javamailproperties mail.smtp.from not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "spring javamailproperties mail.smtp.from not working" Watch "spring javamailproperties mail.smtp.from not working" New topic
Author

spring javamailproperties mail.smtp.from not working

Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
Hello,

I've been trying to smtp.from properties for bounced mails but there is no luck. I dont see any errors. I have set debug to true which does show me from addres but mail is not sent to that address. I'm using fake email id which I know will bounced.
my bean properties are


Any help will be much appreciated. Thank you.

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Have you stepped through the code with your debugger to see exactly what is happening?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
Thanks for reply. I did debug it but cant see anything which can highight the problem. Debug shows following information; in this MAIL FROM is set to desire bouced address but mail is not sent to this address. Is there somehing I need to do diffrently? Thanks.





I changed bean properties little bit, now mail is sent but when its bounced its not going to the bounced address (mail.smtp.from) address but its going to "from" address from mail.


Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Sorry, I am confused

" Debug shows following information;"

How does stepping through code produce printing information. I am talking about debugging where you manually step through your code in your IDE. I am not talking about logging. With debugging you can see every variable and what their current values are. Are you doing that or just logging?

Mark
Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
Hi
I did debug; there is no exception and mail is sent successfully. its that, mail is being sent to "from" addressee instead of one mentioned in javaMailproperties (mail.smtp.from - I used this for bounced mails.) in bean settings. May be i'm not sure what should I look for when I debug this code.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Shilpa Tendulkar wrote:Hi
I did debug; there is no exception and mail is sent successfully. its that, mail is being sent to "from" addressee instead of one mentioned in javaMailproperties (mail.smtp.from - I used this for bounced mails.) in bean settings. May be i'm not sure what should I look for when I debug this code.


When you step through your code, your IDE will show you variable values. So you can go into your mail object and see exactly what the To and From are set to, so you can see if you mistakenly put the wrong value into those properties. You don't necessarily step through code to see an error/exception produced.

Mark
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

I would guess, cause I can't step through your code, is that you are setting the from to something else in code.

Maybe here?



Mark
Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
Hi,

Thanks for your reply. yes. from address is diffrent from the one I used in mail.smtp.from because I want bounce mails to go to mail.smtp.from addres instead of going to "from" address in mail bean. Sorry if I was not clear on stating my problem.

I research through some posts on web, it seems you can set bounce address as mail.smtp.from and bounce mails will be notified to this address. Using spring, one need to specifiy smtp.from in javamailproperties in bean settings. As I'm investigating more on this, it seems, I need to set mail session in context and refer it in the bean properties as well. Do you have any idea on how to do this?
Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
SOLVED

I'm glad I was able to resolved the problem. Task was to send bounce emails to another address than "from" address in the mail. I tried setting headers but apparently smtp server ignores it if error occurs. So solution was to set mail.smtp.from address in the javax.mail.session.
I followed these steps:



Also don't forget to copy or move mail.jar and activation.jar in tomcat/lib or tomcat/endorsed folder.


Hope this helps. If there are any chances of improving this solution please let me know. Thanks.

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Congrats on solving your issue. And thanks for posting your solution to help others out later.

Mark
Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
SOLVED and SIMPLIFIED

Ignore session changes. In my case, you do not need to access session at all. All you have to do is set javaMailProperties in Mailer

in support.xml or wherever mail bean properties are set




This was so easy I couldnt understand how I missed it

Hope this will help.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spring javamailproperties mail.smtp.from not working