本文整理汇总了Java中org.apache.commons.mail.Email.getToAddresses方法的典型用法代码示例。如果您正苦于以下问题:Java Email.getToAddresses方法的具体用法?Java Email.getToAddresses怎么用?Java Email.getToAddresses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.mail.Email
的用法示例。
在下文中一共展示了Email.getToAddresses方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildMessage
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
/**
*
*/
public static Email buildMessage(Email email) throws EmailException {
String from = GojaConfig.getProperty("mail.smtp.from");
if (email.getFromAddress() == null && !StringUtils.isEmpty(from)) {
email.setFrom(from);
} else if (email.getFromAddress() == null) {
throw new MailException("Please define a 'from' email address", new NullPointerException());
}
if ((email.getToAddresses() == null || email.getToAddresses().size() == 0) &&
(email.getCcAddresses() == null || email.getCcAddresses().size() == 0) &&
(email.getBccAddresses() == null || email.getBccAddresses().size() == 0)) {
throw new MailException("Please define a recipient email address",
new NullPointerException());
}
if (email.getSubject() == null) {
throw new MailException("Please define a subject", new NullPointerException());
}
if (email.getReplyToAddresses() == null || email.getReplyToAddresses().size() == 0) {
email.addReplyTo(email.getFromAddress().getAddress());
}
return email;
}
示例2: testCreateMailFor
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@Test
public void testCreateMailFor() throws Throwable
{
PropertiesPerson person = new PropertiesPerson( "person", myPersonProps );
Email email = myClassUnderTest.createMailFor( person );
myLog.debug( "Created Mail: " + email );
Assert.assertNotNull( email );
Assert.assertEquals( THIS_IS_THE_SUBJECT, email.getSubject() );
Object content = Whitebox.getInternalState( email, "content" );
Assert.assertNotNull( content );
Assert.assertEquals( THIS_IS_THE_BODY, content );
List<InternetAddress> addresses = email.getToAddresses();
Assert.assertNotNull( addresses );
Assert.assertEquals( 1, addresses.size() );
}
示例3: buildMessage
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
/**
*
*/
public static Email buildMessage(Email email) throws EmailException {
String from = Play.configuration.getProperty("mail.smtp.from");
if (email.getFromAddress() == null && !StringUtils.isEmpty(from)) {
email.setFrom(from);
} else if (email.getFromAddress() == null) {
throw new MailException("Please define a 'from' email address", new NullPointerException());
}
if ((email.getToAddresses() == null || email.getToAddresses().size() == 0) &&
(email.getCcAddresses() == null || email.getCcAddresses().size() == 0) &&
(email.getBccAddresses() == null || email.getBccAddresses().size() == 0))
{
throw new MailException("Please define a recipient email address", new NullPointerException());
}
if (email.getSubject() == null) {
throw new MailException("Please define a subject", new NullPointerException());
}
if (email.getReplyToAddresses() == null || email.getReplyToAddresses().size() == 0) {
email.addReplyTo(email.getFromAddress().getAddress());
}
return email;
}