commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Pugh <ep...@upstate.com>
Subject Re: Commons - email Help
Date Tue, 30 Aug 2005 10:47:20 GMT
Humm...

One thing is that commons-email is just a wrapper around the JavaMail  
api's, in an attempt to make them easier to use.  commons-email  
doesn't do anything specifically fancy, like precheck if an email  
address works or not.

I would suggest that you write a unit test doing the same thing, but  
using JavaMail directly, just to validate it.  I'm guessing that the  
send() to a local email address does some sort of resolution right  
there, versus queueing it up..  Or, the response from the SMTP server  
is immediate, versus just queuing it up...

Eric

On Aug 29, 2005, at 11:14 AM, Sravan Duggaraju wrote:

> Hi, I recently started Using commons email
> (commons-email-SNAPSHOT.jar) for  send mail functionality.I am facing
> the following problems.
>
> 1)In the To  field if i enter a wrong address of other domain it will
> still send the mail, later it will inform me with "mail delivery
> failure"...this is good. But it is not happening if i send a mail to
> wrong email with in the same domain; it is immediately throwing
>
> javax.mail.SendFailedException: Sending failed;
>   nested exception is:
>     javax.mail.SendFailedException: Invalid Addresses;
>   nested exception is:
>     javax.mail.SendFailedException:
>   ... User unknown
>
> If I am not clear let me explain,
>
> if i send a mail to wrongEmail@otherCompany.com then it is not
> throwing any exception, later I am getting a email saying "delivery
> failed"
>
> but i send mail to wrongEmail@myCompany.com then it is throwing
> runtime exception. and it is not sending to other correct address
> too......How to avoid this?
>
>
> 2)This is related to my question 1.
> In To field i entered correctEmail@mycompany.com and in CC i entered
> wrongEmail@myCompany.com still it is not sending to correct address
> and throughing an exception.
>
>
>     public static void sendMessage(String[] to,String[] cc, String  
> from,
> String subject, String content)
>       throws Exception {
>         SimpleEmail email = new SimpleEmail();
>         email.setHostName("mailserver.mycompany.com");
>         email.setDebug(true);
>         Collection toRecipients = new ArrayList();
>           Collection ccRecipients = new ArrayList();
>           //Create collection of To addresses
>           if(!SBIRUtils.isEmpty(to)){
>
>             for (int i = 0; i < to.length; i++)
>             {
>                 toRecipients.add(new InternetAddress(to[i], null));
>             }
>             email.setTo(toRecipients);
>           }
> //      Create collection of To addresses
>           if(!SBIRUtils.isEmpty(cc)){
>
>             for (int i = 0; i < cc.length; i++)
>             {
>                 ccRecipients.add(new InternetAddress(cc[i], null));
>             }
>             email.setCc(ccRecipients);
>           }
>           email.setFrom(from,from);
>         email.setSubject(subject);
>         email.setMsg(content);
>         email.send();
>     }
>
> I apologize for the big mail.
>
> I appreciate for any help
> San
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message