示例#1
0
  @Test
  public void getTransport() throws Exception {
    Assert.assertSame(SmtpTransport.class, JMSession.getSession().getTransport("smtp").getClass());
    Assert.assertSame(
        SmtpsTransport.class, JMSession.getSession().getTransport("smtps").getClass());

    Assert.assertSame(
        SmtpTransport.class, JMSession.getSmtpSession().getTransport("smtp").getClass());
    Assert.assertSame(
        SmtpsTransport.class, JMSession.getSmtpSession().getTransport("smtps").getClass());
  }
示例#2
0
  @Test
  public void messageID() throws Exception {
    Provisioning prov = Provisioning.getInstance();
    Domain domain = prov.createDomain("example.com", new HashMap<String, Object>());
    Account account =
        prov.createAccount("*****@*****.**", "test123", new HashMap<String, Object>());

    MimeMessage mm = new MimeMessage(JMSession.getSmtpSession(account));
    mm.saveChanges();
    Assert.assertEquals(
        "message ID contains account domain",
        domain.getName() + '>',
        mm.getMessageID().split("@")[1]);
  }
示例#3
0
  // @Test
  public void testRelayMta() throws Exception {
    Provisioning prov = Provisioning.getInstance();
    Server server = prov.getLocalServer();
    server.setShareNotificationMtaHostname("mta02.zimbra.com");
    server.setShareNotificationMtaPort(25);
    server.setShareNotificationMtaAuthRequired(true);
    server.setShareNotificationMtaConnectionType(ShareNotificationMtaConnectionType.STARTTLS);
    server.setShareNotificationMtaAuthAccount("test-jylee");
    server.setShareNotificationMtaAuthPassword("test123");

    SMTPMessage out = new SMTPMessage(JMSession.getRelaySession());
    InternetAddress address = new JavaMailInternetAddress("*****@*****.**");
    out.setFrom(address);

    address = new JavaMailInternetAddress("*****@*****.**");
    out.setRecipient(javax.mail.Message.RecipientType.TO, address);

    out.setSubject("test mail");
    out.setText("hello world");

    out.saveChanges();
    ZimbraLog.smtp.setLevel(Level.trace);
    Transport.send(out);
  }