commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Flatoff Allan" <Allan.Flat...@sentry.com>
Subject RE: Commons - [email] Help
Date Mon, 29 Aug 2005 16:15:37 GMT
Hmm. . .

Couldn't you just catch the SendFailedException and generate your own
"mail delivery failure" message
To the sender?  Sounds like this is how you want it to behave.

--Allan

-----Original Message-----
From: Sravan Duggaraju [mailto:saaan.di@gmail.com] 
Sent: Monday, August 29, 2005 10:14 AM
To: commons-user@jakarta.apache.org
Subject: Commons - email Help

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



This e-mail is confidential.  If you are not the intended recipient, you must not disclose
or use the information contained in it.  If you have received this e-mail in error, please
tell us immediately by return e-mail to Email.Control@sentry.com and delete the document.

E-mails containing unprofessional, discourteous or offensive remarks violate Sentry policy.
You may report employee violations by forwarding the message to Email.Control@sentry.com.

No recipient may use the information in this e-mail in violation of any civil or criminal
statute. Sentry disclaims all liability for any unauthorized uses of this e-mail or its contents.

This e-mail constitutes neither an offer nor an acceptance of any offer. No contract may be
entered into by a Sentry employee without express approval from an authorized Sentry manager.

Warning: Computer viruses can be transmitted via e-mail. Sentry accepts no liability or responsibility
for any damage caused by any virus transmitted with this e-mail.


---------------------------------------------------------------------
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