commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sravan Duggaraju <saaan...@gmail.com>
Subject Commons - email Help
Date Mon, 29 Aug 2005 15:14:27 GMT
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


Mime
View raw message