当前位置: 首页>>代码示例>>Java>>正文


Java SmtpMessage类代码示例

本文整理汇总了Java中com.dumbster.smtp.SmtpMessage的典型用法代码示例。如果您正苦于以下问题:Java SmtpMessage类的具体用法?Java SmtpMessage怎么用?Java SmtpMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SmtpMessage类属于com.dumbster.smtp包,在下文中一共展示了SmtpMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSendEmail_expectMailDIliveredToVirtualServer

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void testSendEmail_expectMailDIliveredToVirtualServer() throws Exception {
	EmailSenderImpl fixture = new EmailSenderImpl();
	fixture.setEmailChannelProperties(new EmailChannelPropertiesTestImpl());
	EmailMessage emailMessage = new EmailMessage();
	emailMessage.setFromName("fromName");
	emailMessage.setFromAddress("[email protected]");
	emailMessage.setToAddress("[email protected]");
	emailMessage.setToName("toName");
	emailMessage.setSubject("ssubj");
	emailMessage.setBody("bbody");

	fixture.sendEmail(emailMessage);

	assertTrue(server.getReceivedEmailSize() == 1);
	@SuppressWarnings("rawtypes")
	Iterator emailIter = server.getReceivedEmail();
	SmtpMessage email = (SmtpMessage) emailIter.next();
	assertTrue(email.getHeaderValue("Subject").equals("ssubj"));
	assertTrue(email.getBody().equals("bbody"));
}
 
开发者ID:skarpushin,项目名称:summerb,代码行数:22,代码来源:EmailSenderImplTest.java

示例2: assertMail

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
public static void assertMail(
    SimpleSmtpServer server,
    String from,
    String to,
    String replyTo,
    String subject,
    String mimeType,
    String body,
    String attachmentContentID,
    String attachmentFileName) {
  assertEquals(server.getReceivedEmails().size(), 1);
  SmtpMessage email = server.getReceivedEmails().iterator().next();

  assertEquals(email.getHeaderValue("Subject"), subject);
  assertEquals(email.getHeaderValue("From"), from);
  assertEquals(email.getHeaderValue("Reply-To"), replyTo);
  assertEquals(email.getHeaderValue("To"), to);
  assertTrue(email.getBody().contains("Content-Type: " + mimeType));
  assertTrue(email.getBody().contains(body));
  if (attachmentFileName != null && attachmentContentID != null) {
    assertTrue(email.getBody().contains("filename=" + attachmentFileName));
    assertTrue(email.getBody().contains("Content-ID: <" + attachmentContentID + ">"));
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:MailSenderTest.java

示例3: sendEmailSuccessTest

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
/**
 * Test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void sendEmailSuccessTest() throws Exception {
	final CreateApplicationSessionRequest createSessionRequest = createTestApplicationSession();

	final SendEmailRequest serviceRequest = new SendEmailRequest();
	serviceRequest.setSessionId(createSessionRequest.getSessionId());
	serviceRequest.setEmail("[email protected]");
	serviceRequest.setSubject("Test Email SendEmailServiceITest");
	serviceRequest.setContent("Test content");

	final SendEmailResponse response = (SendEmailResponse) applicationManager
			.service(serviceRequest);
	assertNotNull(EXPECT_A_RESULT, response);

	final List<SmtpMessage> emails = dumbster.getReceivedEmails();
	assertEquals(emails.size(), 1);
	final SmtpMessage email = emails.get(0);
	assertEquals(email.getHeaderValue("Subject"), serviceRequest.getSubject());
	assertEquals(email.getBody(), serviceRequest.getContent());
	assertEquals(email.getHeaderValue("To"), serviceRequest.getEmail());

}
 
开发者ID:Hack23,项目名称:cia,代码行数:29,代码来源:SendEmailServiceITest.java

示例4: send

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void send() {
	LostPasswordSpammer spammer = new LostPasswordSpammer(config);

	User user = new User();
	user.setEmail("[email protected]");
	user.setActivationKey("123");

	spammer.prepare(user, "lost subject");

	SimpleSmtpServer server = null;

	try {
		server = SimpleSmtpServer.start(config.getInt(ConfigKeys.MAIL_SMTP_PORT));
		spammer.dispatchMessages();
	}
	finally {
		if (server != null) {
			server.stop();
		}
	}

	Assert.assertEquals(1, server.getReceivedEmailSize());
	SmtpMessage message = (SmtpMessage)server.getReceivedEmail().next();
	Assert.assertTrue(message.getBody().indexOf("http://localhost/user/recoverPassword/123.page") > -1);
}
 
开发者ID:eclipse123,项目名称:JForum,代码行数:27,代码来源:LostPasswordSpammerTestCase.java

示例5: shouldSendTextOnlyEmail

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void shouldSendTextOnlyEmail() {
  Spitter spitter = new Spitter();
  spitter.setFullName("Test McTest");
  Spittle spittle = new Spittle();
  spittle.setSpitter(spitter);
  spittle.setText("This is a test");

  assertEquals(0, smtpServer.getReceivedEmailSize());

  emailService.sendSimpleSpittleEmail("[email protected]", spittle);
  
  assertEquals(1, smtpServer.getReceivedEmailSize());
  
  SmtpMessage email = (SmtpMessage) smtpServer.getReceivedEmail().next();
  assertEquals("New spittle from Test McTest", email.getHeaderValue("Subject"));
  assertEquals("[email protected]", email.getHeaderValue("From"));
  assertEquals("[email protected]", email.getHeaderValue("To"));
  assertEquals("This is a test", email.getBody());
}
 
开发者ID:liuxianqiang,项目名称:spring-in-action,代码行数:21,代码来源:SpitterEmailServiceImplTest.java

示例6: shouldSendHtmlEmail

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void shouldSendHtmlEmail() throws MessagingException {
  Spitter spitter = new Spitter();
  spitter.setFullName("Test McTest");
  Spittle spittle = new Spittle();
  spittle.setSpitter(spitter);
  spittle.setText("This is a test");

  assertEquals(0, smtpServer.getReceivedEmailSize());

  emailService.sendRichSpitterEmail("[email protected]", spittle);
  
  assertEquals(1, smtpServer.getReceivedEmailSize());
  
  SmtpMessage email = (SmtpMessage) smtpServer.getReceivedEmail().next();
  assertEquals("New spittle from Test McTest", email.getHeaderValue("Subject"));
  assertEquals("[email protected]", email.getHeaderValue("From"));
  assertEquals("[email protected]", email.getHeaderValue("To"));
  assertEquals("multipart/mixed;", email.getHeaderValue("Content-Type"));
  
}
 
开发者ID:liuxianqiang,项目名称:spring-in-action,代码行数:22,代码来源:SpitterEmailServiceImplTest.java

示例7: sendMail

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void sendMail() throws MessagingException{
	MailAccount account = new MailAccount();
	account.setId("testSmtpAccount");
	account.setType(TYPE.SMTP);
	account.setUsername("[email protected]");
	account.setPassword("testPassword");
	account.setHost("localhost");
	account.setPort("25");
	
	MailMessage message = new MailMessage().to("[email protected]").subject("subject").text("text");
	assertTrue(client.sendMail(account, message));
	
	assertTrue(server.getReceivedEmailSize() == 1);
	Iterator<?> emailIter = server.getReceivedEmail();
	SmtpMessage email = (SmtpMessage) emailIter.next();
	assertTrue(email.getHeaderValue("Subject").equals("subject"));
	assertTrue(email.getBody().contains("text"));
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:20,代码来源:MailClientTest.java

示例8: testSendEmail_WithWorkingCredentials_ShouldWork

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void testSendEmail_WithWorkingCredentials_ShouldWork() throws InvalidEmailServerConfigurationException {		
	User lockedOutUser = new User();
	lockedOutUser.setRecoveryEmail("[email protected]");
	lockedOutUser.setUnlockCode("12345");
	
	service.sendUnlockCodeEmailFor(lockedOutUser);
		
	SmtpMessage message = dumbster.getReceivedEmails().get(0);
	assertNotNull(message);
	assertTrue(message.getBody().contains("12345"));
	assertTrue(message.getBody().contains("unlock"));
	
	dumbster.reset();
}
 
开发者ID:daflockinger,项目名称:poppynotes,代码行数:16,代码来源:EmailServiceTest.java

示例9: notifyAssign

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void notifyAssign() {
   log.debug("start notifyAssign()");
   Controllable c = createControllable(ExecutionStatus.POSTPONED);
   JpaResource res = new JpaResource(new TEntity());
   c.setResource(res);

   EmailNotificationProvider prov = new EmailNotificationProvider();
   prov.setFrom("[email protected]");
   prov.setSmtpHost("localhost");
   prov.setSmtpPort("8854");

   SimpleSmtpServer server = SimpleSmtpServer.start(8854);
   try {
      prov.notify(ExecutionStatus.POSTPONED, c);

      server.stop();

      Assert.assertTrue(server.getReceivedEmailSize() == 1);
      Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
      SmtpMessage email = emailIter.next();
      Assert.assertEquals("Cibet Notification: POSTPONED", email.getHeaderValue("Subject"));
      log.debug(email.getBody());

      String exp = "Hello approvalUser,\n\n"
            + "A business case under dual control has been assigned to you for final approval. You may release or reject the case. Please visit the dialogue for releasing/rejecting.\n"
            + "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
            + "control event:             DELETE\n"
            + "controlled target:         com.cibethelper.entities.TEntity \n"
            + "initiated by:              userId on Fri Sep 20 16:13:22 CEST 2013\n"
            + "first released by:         firstApprovalUserId on Sun Sep 22 16:13:22 CEST 2013\n\n\n"
            + "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
      Assert.assertEquals(exp, email.getBody());
   } finally {
      server.stop();
   }
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:38,代码来源:EmailNotificationProviderTest.java

示例10: notifyAssign2

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void notifyAssign2() {
   log.debug("start notifyAssign2()");
   Controllable c = createControllable(ExecutionStatus.POSTPONED);
   JpaResource res = new JpaResource(new TEntity());
   c.setResource(res);

   c.setFirstApprovalUser(null);
   c.setFirstApprovalAddress(null);
   c.setFirstApprovalDate(null);
   EmailNotificationProvider prov = new EmailNotificationProvider();
   prov.setFrom("[email protected]");
   prov.setSmtpHost("localhost");
   prov.setSmtpPort("8854");

   SimpleSmtpServer server = SimpleSmtpServer.start(8854);
   try {
      prov.notify(ExecutionStatus.POSTPONED, c);

      server.stop();

      Assert.assertTrue(server.getReceivedEmailSize() == 1);
      Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
      SmtpMessage email = emailIter.next();
      Assert.assertEquals("Cibet Notification: POSTPONED", email.getHeaderValue("Subject"));
      log.debug(email.getBody());

      String exp = "Hello approvalUser,\n\n"
            + "A business case under dual control has been assigned to you for final approval. You may release or reject the case. Please visit the dialogue for releasing/rejecting.\n"
            + "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
            + "control event:             DELETE\n"
            + "controlled target:         com.cibethelper.entities.TEntity \n"
            + "initiated by:              userId on Fri Sep 20 16:13:22 CEST 2013\n\n\n\n"
            + "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
      Assert.assertEquals(exp, email.getBody());
   } finally {
      server.stop();
   }
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:40,代码来源:EmailNotificationProviderTest.java

示例11: notifyFirstReleased

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void notifyFirstReleased() {
   log.debug("start notifyFirstReleased()");
   Controllable c = createControllable(ExecutionStatus.FIRST_RELEASED);
   JpaResource res = new JpaResource(new TEntity());
   c.setResource(res);

   EmailNotificationProvider prov = new EmailNotificationProvider();
   prov.setFrom("[email protected]");
   prov.setSmtpHost("localhost");
   prov.setSmtpPort("8854");

   SimpleSmtpServer server = SimpleSmtpServer.start(8854);
   try {
      prov.notify(ExecutionStatus.FIRST_RELEASED, c);

      server.stop();

      Assert.assertTrue(server.getReceivedEmailSize() == 1);
      Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
      SmtpMessage email = emailIter.next();
      Assert.assertEquals("Cibet Notification: FIRST_RELEASED", email.getHeaderValue("Subject"));
      Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
      Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
      log.debug(email.getBody());

      String exp = "Hello userId,\n\n"
            + "A business case under 6-eyes dual control has been released by the first approval user.\n"
            + "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
            + "control event:             DELETE\n"
            + "controlled target:         com.cibethelper.entities.TEntity \n"
            + "initiated by:              userId on Fri Sep 20 16:13:22 CEST 2013\n"
            + "first released by:         firstApprovalUserId on Sun Sep 22 16:13:22 CEST 2013\n\n\n"
            + "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
      Assert.assertEquals(exp, email.getBody());
   } finally {
      server.stop();
   }
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:40,代码来源:EmailNotificationProviderTest.java

示例12: notifyFirstReleased2

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void notifyFirstReleased2() {
   log.debug("start notifyFirstReleased2()");
   Controllable c = createControllable(ExecutionStatus.FIRST_RELEASED);
   EjbResource res = new EjbResource(new TEntity(), null, null);
   res.setMethod("executePay");
   c.setResource(res);

   EmailNotificationProvider prov = new EmailNotificationProvider();
   prov.setFrom("[email protected]");
   prov.setSmtpHost("localhost");
   prov.setSmtpPort("8854");

   SimpleSmtpServer server = SimpleSmtpServer.start(8854);
   try {
      prov.notify(ExecutionStatus.FIRST_RELEASED, c);

      server.stop();

      Assert.assertTrue(server.getReceivedEmailSize() == 1);
      Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
      SmtpMessage email = emailIter.next();
      Assert.assertEquals("Cibet Notification: FIRST_RELEASED", email.getHeaderValue("Subject"));
      Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
      Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
      log.debug(email.getBody());

      String exp = "Hello userId,\n\n"
            + "A business case under 6-eyes dual control has been released by the first approval user.\n"
            + "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
            + "control event:             DELETE\n"
            + "controlled target:         com.cibethelper.entities.TEntity (executePay)\n"
            + "initiated by:              userId on Fri Sep 20 16:13:22 CEST 2013\n"
            + "first released by:         firstApprovalUserId on Sun Sep 22 16:13:22 CEST 2013\n\n\n"
            + "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
      Assert.assertEquals(exp, email.getBody());
   } finally {
      server.stop();
   }
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:41,代码来源:EmailNotificationProviderTest.java

示例13: notifyRejected

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void notifyRejected() {
   log.debug("start notifyRejected()");
   Controllable c = createControllable(ExecutionStatus.REJECTED);
   JpaResource res = new JpaResource(new TEntity());
   c.setResource(res);

   EmailNotificationProvider prov = new EmailNotificationProvider();
   prov.setFrom("[email protected]");
   prov.setSmtpHost("localhost");
   prov.setSmtpPort("8854");

   SimpleSmtpServer server = SimpleSmtpServer.start(8854);
   try {
      prov.notify(ExecutionStatus.REJECTED, c);

      server.stop();

      Assert.assertTrue(server.getReceivedEmailSize() == 1);
      Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
      SmtpMessage email = emailIter.next();
      Assert.assertEquals("Cibet Notification: REJECTED", email.getHeaderValue("Subject"));
      Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
      Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
      log.debug(email.getBody());

      String exp = "Hello userId,\n\n" + "A business case under dual control has been rejected.\n"
            + "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
            + "control event:             DELETE\n"
            + "controlled target:         com.cibethelper.entities.TEntity \n"
            + "initiated by:              userId on Fri Sep 20 16:13:22 CEST 2013\n"
            + "first released by:         firstApprovalUserId on Sun Sep 22 16:13:22 CEST 2013\n"
            + "rejected by:               approvalUser on Wed Sep 25 16:13:22 CEST 2013\n\n\n"
            + "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
      Assert.assertEquals(exp, email.getBody());
   } finally {
      server.stop();
   }
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:40,代码来源:EmailNotificationProviderTest.java

示例14: notifyReleased

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void notifyReleased() {
   log.debug("start notifyReleased()");
   Controllable c = createControllable(ExecutionStatus.EXECUTED);
   JpaResource res = new JpaResource(new TEntity());
   c.setResource(res);

   EmailNotificationProvider prov = new EmailNotificationProvider();
   prov.setFrom("[email protected]");
   prov.setSmtpHost("localhost");
   prov.setSmtpPort("8854");

   SimpleSmtpServer server = SimpleSmtpServer.start(8854);
   try {
      prov.notify(ExecutionStatus.EXECUTED, c);

      server.stop();

      Assert.assertTrue(server.getReceivedEmailSize() == 1);
      Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
      SmtpMessage email = emailIter.next();
      Assert.assertEquals("Cibet Notification: EXECUTED", email.getHeaderValue("Subject"));
      Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
      Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
      log.debug(email.getBody());

      String exp = "Hello userId,\n\n" + "A business case under dual control has been finally released.\n"
            + "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
            + "control event:             DELETE\n"
            + "controlled target:         com.cibethelper.entities.TEntity \n"
            + "initiated by:              userId on Fri Sep 20 16:13:22 CEST 2013\n"
            + "first released by:         firstApprovalUserId on Sun Sep 22 16:13:22 CEST 2013\n"
            + "released by:               approvalUser on Wed Sep 25 16:13:22 CEST 2013\n\n\n"
            + "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
      Assert.assertEquals(exp, email.getBody());
   } finally {
      server.stop();
   }
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:40,代码来源:EmailNotificationProviderTest.java

示例15: testSendEmail_expectMailDIliveredToVirtualServer

import com.dumbster.smtp.SmtpMessage; //导入依赖的package包/类
@Test
public void testSendEmail_expectMailDIliveredToVirtualServer() throws Exception {
	EmailSenderImpl actual = new EmailSenderImpl();
	actual.setEmailChannelProperties(new EmailChannelPropertiesTestImpl());

	ExecutorService executor = Executors.newSingleThreadExecutor();
	EmailSenderSimpleQueueImpl fixture = new EmailSenderSimpleQueueImpl(actual, executor);

	EmailMessage emailMessage = new EmailMessage();
	emailMessage.setFromName("fromName");
	emailMessage.setFromAddress("[email protected]");
	emailMessage.setToAddress("[email protected]");
	emailMessage.setToName("toName");
	emailMessage.setSubject("ssubj");
	emailMessage.setBody("bbody1");

	fixture.sendEmail(emailMessage);
	executor.shutdown();
	executor.awaitTermination(5, TimeUnit.SECONDS);

	assertTrue(server.getReceivedEmailSize() == 1);
	@SuppressWarnings("rawtypes")
	Iterator emailIter = server.getReceivedEmail();
	SmtpMessage email = (SmtpMessage) emailIter.next();
	assertTrue(email.getHeaderValue("Subject").equals("ssubj"));
	assertTrue(email.getBody().equals("bbody1"));
}
 
开发者ID:skarpushin,项目名称:summerb,代码行数:28,代码来源:EmailSenderQueueImplTest.java


注:本文中的com.dumbster.smtp.SmtpMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。