R
Rico
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Pattern p = Pattern.compile("@[a-zA-Z_0-9<>\\-\\;\\,\\.]*@");
Matcher m = p.matcher(user_info.getEmailAddress());
boolean b = m.find();
if (!b) // Does _not_ match 2 or more email addresses
{
InternetAddress[] addr = {new InternetAddress(user_info
.getEmailAddress(), user_info.getName())};
msg.addRecipients(Message.RecipientType.TO, addr);
} else
msg.addRecipients(Message.RecipientType.TO, user_info
.getEmailAddress());
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
In the above code, I use the regular expression to detect whether I
have at least 2 email addresses to send the message to.
This is because I can't figure out how to attach a 'name' string
to a group of email addresses in JavaMail. So in the first case when
the match fails (only 1 email address) I can afford to put the name
string, otherwise, I don't.
Previously a hyphen in the domain name caused the regular expression
to fail to detect 2 email addresses because I didn't include it as a
possible literal.
Now, if I use (e-mail address removed);[email protected] , wanting to be RFC822 compliant,
Javamail complains that the semi-colon is illegal: not in group.
Trivial fix is to replace the semi-colon with comma.
Yet, not that I lack other things to do, I did go and read RFC822 to
find out how to associate a name with a list of email addresses and
they say:
group = phrase ":" [#mailbox] ";"
The part between square brackets is my list of email addresses, separated
by commas.
So, that'd mean I use:
"marc and tommy":[email protected],[email protected];
Not surprisingly, it doesn't work.
Maybe someone could please help me make sense of what I've read then.
How do I associate a name string with a group of email addresses?
And where does JavaMail expect the semi-colon to be for a group? Thanks.
Rico.
Pattern p = Pattern.compile("@[a-zA-Z_0-9<>\\-\\;\\,\\.]*@");
Matcher m = p.matcher(user_info.getEmailAddress());
boolean b = m.find();
if (!b) // Does _not_ match 2 or more email addresses
{
InternetAddress[] addr = {new InternetAddress(user_info
.getEmailAddress(), user_info.getName())};
msg.addRecipients(Message.RecipientType.TO, addr);
} else
msg.addRecipients(Message.RecipientType.TO, user_info
.getEmailAddress());
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
In the above code, I use the regular expression to detect whether I
have at least 2 email addresses to send the message to.
This is because I can't figure out how to attach a 'name' string
to a group of email addresses in JavaMail. So in the first case when
the match fails (only 1 email address) I can afford to put the name
string, otherwise, I don't.
Previously a hyphen in the domain name caused the regular expression
to fail to detect 2 email addresses because I didn't include it as a
possible literal.
Now, if I use (e-mail address removed);[email protected] , wanting to be RFC822 compliant,
Javamail complains that the semi-colon is illegal: not in group.
Trivial fix is to replace the semi-colon with comma.
Yet, not that I lack other things to do, I did go and read RFC822 to
find out how to associate a name with a list of email addresses and
they say:
group = phrase ":" [#mailbox] ";"
The part between square brackets is my list of email addresses, separated
by commas.
So, that'd mean I use:
"marc and tommy":[email protected],[email protected];
Not surprisingly, it doesn't work.
Maybe someone could please help me make sense of what I've read then.
How do I associate a name string with a group of email addresses?
And where does JavaMail expect the semi-colon to be for a group? Thanks.
Rico.