from = from.trim().toLowerCase();
to = to.trim().toLowerCase();
boolean fromOk = from.matches(emailRegexp);
if(!fromOk)
throw new AddressException("Invalid from address:" + from);
boolean toOk = to.matches(emailRegexp);
if(!toOk)
throw new AddressException("Invalid to address:" + to);
if(cc != null && !cc.equals(""))
{
StringBuffer sb = new StringBuffer();
String[] emailAddresses = cc.split(";");
for(int i=0; i<emailAddresses.length; i++)
{
String email = emailAddresses[i].trim().toLowerCase();
boolean emailOk = email.matches(emailRegexp);
if(!emailOk && emailAddresses.length == 1)
{
throw new AddressException("Invalid cc address:" + email);
}
else if(emailOk)
{
if(sb.length() > 0)
sb.append(";");
sb.append(email);
}
}
cc = sb.toString();
if(cc.equals(""))
cc = null;
}
if(cc != null && cc.equals(""))
cc = null;
if(bcc == null && recipients != null)
bcc = recipients;
if(bcc != null && !bcc.equals(""))
{
StringBuffer sb = new StringBuffer();
String[] emailAddresses = bcc.split(";");
for(int i=0; i<emailAddresses.length; i++)
{
String email = emailAddresses[i].trim().toLowerCase();
boolean emailOk = email.matches(emailRegexp);
if(!emailOk && emailAddresses.length == 1)
{
throw new AddressException("Invalid bcc/recipients address:" + email);
}
else if(emailOk)
{
if(sb.length() > 0)
sb.append(";");