• 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

JavaMail: setting multiple reply-to values

 
Ranch Hand
Posts: 68
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to set replyTo attribute in my Java mail email (to more than one email address) , I was able to set one email address and worked fine

                     

tried this,

how could I pass the list?
Any help?
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There can only be a single Reply-To address for any email you send out. If you want to send multiple emails with different Reply-To addresses, then you'll have to compose those individually.
 
Samar Land
Ranch Hand
Posts: 68
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mmmm,  how so? I couldn't figure it out.
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What did you try? Instead of creating one mail, and setting a list of addresses, you would create multiple mails, each with its own To and Reply-To address.

See https://coderanch.com/wiki/660091/Java-Enterprise-Edition-Faq for lots of useful links regarding JavaMail, including the definitive FAQ and lots of example code.
 
Marshal
Posts: 4491
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Samar Land wrote:


You should be able to provide a list of Reply-To addresses (no guarantees what the email servers between you and the recipient will do with these addresses though).

I'm not sure what abb is for, but the commas appended to the email addresses will probably be a problem.

As a test, try something simpler like:
 
Samar Land
Ranch Hand
Posts: 68
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was able to get it working when I passed my list like:

 
Ron McLeod
Marshal
Posts: 4491
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The setReplyTo method takes a Address[] parameter (or sub-classes like InternetAddress[] or NewsAddress[]).  I'm not sure how you made this work by passing in a String[].
 
Ron McLeod
Marshal
Posts: 4491
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Samar Land wrote:I was able to get it working when I passed ...


Does this mean that your issue has been resolved?
 
Samar Land
Ranch Hand
Posts: 68
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:

Samar Land wrote:I was able to get it working when I passed ...


Does this mean that your issue has been resolved?



Yes!
Thank you for all of your advises.
 
Samar Land
Ranch Hand
Posts: 68
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:

The setReplyTo method takes a Address[] parameter (or sub-classes like InternetAddress[] or NewsAddress[]).  I'm not sure how you made this work by passing in a String[].



I passed the ((InternetAddress[] mailAddress_TO))

String abb = user.getStoreAbbreviation();
               mailAddressTo[0] = abb + "test1@test.com" + ",";    
               mailAddressTo[1] = abb + "test2@test.com" + ",";    
               mailAddressTo[2] = abb + "test3@test.com";
               InternetAddress[] mailAddress_TO = new InternetAddress[mailAddressTo.length];
               for (int i = 0; i < mailAddressTo.length; i++) {
                   mailAddress_TO[i] = new InternetAddress(mailAddressTo[i]);
               }
 
Samar Land
Ranch Hand
Posts: 68
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:

The setReplyTo method takes a Address[] parameter (or sub-classes like InternetAddress[] or NewsAddress[]).  I'm not sure how you made this work by passing in a String[].



I passed the ((InternetAddress[] mailAddress_TO))
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think Ron got confused because you have a String[] mailAddressTo and an InternetAddress[] mailAddress_TO - the two are named almost exactly the same.
 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic