• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

spring javamailproperties mail.smtp.from not working

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you stepped through the code with your debugger to see exactly what is happening?

Mark
 
Shilpa Tendulkar
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congrats on solving your issue. And thanks for posting your solution to help others out later.

Mark
 
Shilpa Tendulkar
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic