• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problem with sending E-mail

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I've a problem with sending an E-mail to multiple reciepients.

This is the method that gets all the E-mail addresses I have:


Here I call my methode:


My Mail.java:


And this is the Exception what I still get:



Could soemone help me to fix this problem???

Abu Romaysa,
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are getting the toString of the String array and not the String at an array position:


Change this to:

Try it again.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to be trying to pass an array of strings to a constructor which does not accept string arrays in Mail.java:

Thats not going to work.
 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replays,

I tried what you said but still get this Exception:
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Print out the list of email addresses you are sending this to. That should clarify things
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the addresses are now valid SMTP email addresses (otherwise you'd still see the AddressException) but your SMTP server is sending back a 550 message. That means the requested action cannot be taken, because the mailbox is unavailable to whichever user tried to preform the action, either because it doesn't exist or access is denied (you can find this out by reading the right RFC by the way).
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
InternetAdress validates the String is a valid Internet Address and not a valid Email address (not even in form) A lot of Strings are valid Internet Addresses but, not a validly formed email address. The failure he is getting now is caused by one of the Strings in the list. It appears to be a comma or empty String. Scrubbing a List of String to ensure each is a valid appearing email address takes a bit more work.
 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes the problem is in the method that gets the e-mails addresses from the database.

When I printed out the result of my array I got this: [Ljava.lang.String;@d17ec3
and that means an invalid e-mail address.

is something wrong with my methode?

 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to read up on Arrays in Java but, try this:

 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Carl,

Here is what I got when I tried to send an e-mail:

Address # 0 : null
Address # 1 : null
[ January 31, 2005: Message edited by: Azz Romaysa ]
 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very very much ...

The problem is fixed. The problem was in the method that gets the e-mail addresses, it returned a null, cause the way how I converted my Vector to an Array was wrong.

This has fixed the problem: String[] mijnEmails = (String[]) emails.toArray(new String[emails.size()]);

Abu Romaysa,
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


InternetAdress validates the String is a valid Internet Address and not a valid Email address (not even in form) A lot of Strings are valid Internet Addresses but, not a validly formed email address. The failure he is getting now is caused by one of the Strings in the list. It appears to be a comma or empty String. Scrubbing a List of String to ensure each is a valid appearing email address takes a bit more work


Well actually the InternetAddresses class parses the String to ensure its RFC822 compliant, unless you tell it not to. 822 compliant == a valid SMTP email address. Passing a null to the constructor is not valid, unless you do as Azz Romaysa has done and concatenate a blank string onto it.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic