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


Java SMTPClient.helo方法代码示例

本文整理汇总了Java中org.apache.commons.net.smtp.SMTPClient.helo方法的典型用法代码示例。如果您正苦于以下问题:Java SMTPClient.helo方法的具体用法?Java SMTPClient.helo怎么用?Java SMTPClient.helo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.net.smtp.SMTPClient的用法示例。


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

示例1: testTwoSimultaneousMails

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
public void testTwoSimultaneousMails() throws Exception {
    finishSetUp(m_testConfiguration);

    SMTPClient smtpProtocol1 = new SMTPClient();
    smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort);
    SMTPClient smtpProtocol2 = new SMTPClient();
    smtpProtocol2.connect("127.0.0.1", m_smtpListenerPort);

    assertTrue("first connection taken", smtpProtocol1.isConnected());
    assertTrue("second connection taken", smtpProtocol2.isConnected());

    // no message there, yet
    assertNull("no mail received by mail server", queue.getLastMail());

    smtpProtocol1.helo(InetAddress.getLocalHost().toString());
    smtpProtocol2.helo(InetAddress.getLocalHost().toString());

    String sender1 = "[email protected]";
    String recipient1 = "[email protected]";
    smtpProtocol1.setSender(sender1);
    smtpProtocol1.addRecipient(recipient1);

    String sender2 = "[email protected]";
    String recipient2 = "[email protected]";
    smtpProtocol2.setSender(sender2);
    smtpProtocol2.addRecipient(recipient2);

    smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body testTwoSimultaneousMails1\r\n.\r\n");
    verifyLastMail(sender1, recipient1, null);

    smtpProtocol2.sendShortMessageData("Subject: test\r\n\r\nTest body testTwoSimultaneousMails2\r\n.\r\n");
    verifyLastMail(sender2, recipient2, null);

    smtpProtocol1.quit();
    smtpProtocol2.quit();

    smtpProtocol1.disconnect();
    smtpProtocol2.disconnect();
}
 
开发者ID:twachan,项目名称:James,代码行数:40,代码来源:SMTPServerTest.java

示例2: testTwoMailsInSequence

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
public void testTwoMailsInSequence() throws Exception {
    finishSetUp(m_testConfiguration);

    SMTPClient smtpProtocol1 = new SMTPClient();
    smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort);

    assertTrue("first connection taken", smtpProtocol1.isConnected());

    // no message there, yet
    assertNull("no mail received by mail server", queue.getLastMail());

    smtpProtocol1.helo(InetAddress.getLocalHost().toString());

    String sender1 = "[email protected]";
    String recipient1 = "[email protected]";
    smtpProtocol1.setSender(sender1);
    smtpProtocol1.addRecipient(recipient1);

    smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body testTwoMailsInSequence1\r\n");
    verifyLastMail(sender1, recipient1, null);

    String sender2 = "[email protected]";
    String recipient2 = "[email protected]";
    smtpProtocol1.setSender(sender2);
    smtpProtocol1.addRecipient(recipient2);

    smtpProtocol1.sendShortMessageData("Subject: test2\r\n\r\nTest body2 testTwoMailsInSequence2\r\n");
    verifyLastMail(sender2, recipient2, null);

    smtpProtocol1.quit();
    smtpProtocol1.disconnect();
}
 
开发者ID:twachan,项目名称:James,代码行数:33,代码来源:SMTPServerTest.java

示例3: testHeloResolvDefault

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
public void testHeloResolvDefault() throws Exception {
    finishSetUp(m_testConfiguration);

    SMTPClient smtpProtocol1 = new SMTPClient();
    smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort);

    smtpProtocol1.helo("abgsfe3rsf.de");
    // helo should not be checked. so this should give a 250 code
    assertEquals("Helo accepted", 250, smtpProtocol1.getReplyCode());

    smtpProtocol1.quit();
}
 
开发者ID:twachan,项目名称:James,代码行数:13,代码来源:SMTPServerTest.java

示例4: send

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
public SmtpResponse send(String domain, Mail mail) throws IOException {
    SMTPClient client = new SMTPClient();
    client.connect(address, port);
    try {
        int replyCode = client.getReplyCode();
        if (!SMTPReply.isPositiveCompletion(replyCode))
            return new SmtpResponse(replyCode);
            //return error("SMTP connect failed with reply code " + replyCode);

        replyCode = client.helo(domain);
        if (!SMTPReply.isPositiveCompletion(replyCode))
            return new SmtpResponse(replyCode);
            //return error("SMTP HELO failed with reply code " + replyCode);

        replyCode = client.mail(mail.getFrom());
        if (!SMTPReply.isPositiveCompletion(replyCode))
            return new SmtpResponse(replyCode);
            //return error("SMTP MAIL FROM failed with reply code " + replyCode);

        replyCode = client.rcpt(mail.getTo());
        if (!SMTPReply.isPositiveCompletion(replyCode))
            return new SmtpResponse(replyCode);
            //return error("SMTP RCTP TO failed with reply code " + replyCode);

        client.quit();

    } finally {
        client.disconnect();
    }

    return new SmtpResponse(SMTPReply.SERVICE_CLOSING_TRANSMISSION_CHANNEL);
}
 
开发者ID:chaquotay,项目名称:whiskers,代码行数:33,代码来源:SmtpHost.java

示例5: testSenderDomainResolv

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
public void testSenderDomainResolv() throws Exception {
    m_testConfiguration.setSenderDomainResolv();
    m_testConfiguration.setAuthorizedAddresses("192.168.0.1/32");
    finishSetUp(m_testConfiguration);

    SMTPClient smtpProtocol1 = new SMTPClient();
    smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort);

    assertTrue("first connection taken", smtpProtocol1.isConnected());

    // no message there, yet
    assertNull("no mail received by mail server", queue.getLastMail());

    smtpProtocol1.helo(InetAddress.getLocalHost().toString());

    String sender1 = "[email protected]";

    smtpProtocol1.setSender(sender1);
    assertEquals("expected 501 error", 501, smtpProtocol1.getReplyCode());

    smtpProtocol1.addRecipient("[email protected]");
    assertEquals("Recipient not accepted cause no valid sender", 503, smtpProtocol1.getReplyCode());
    smtpProtocol1.quit();

}
 
开发者ID:twachan,项目名称:James,代码行数:26,代码来源:SMTPServerTest.java

示例6: testSenderDomainResolvRelayClientDefault

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
public void testSenderDomainResolvRelayClientDefault() throws Exception {
    m_testConfiguration.setSenderDomainResolv();
    finishSetUp(m_testConfiguration);

    SMTPClient smtpProtocol1 = new SMTPClient();
    smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort);

    assertTrue("first connection taken", smtpProtocol1.isConnected());

    // no message there, yet
    assertNull("no mail received by mail server", queue.getLastMail());

    smtpProtocol1.helo(InetAddress.getLocalHost().toString());

    String sender1 = "[email protected]";

    // Both mail shold
    smtpProtocol1.setSender(sender1);

    smtpProtocol1.quit();

}
 
开发者ID:twachan,项目名称:James,代码行数:23,代码来源:SMTPServerTest.java

示例7: testSenderDomainResolvRelayClient

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
public void testSenderDomainResolvRelayClient() throws Exception {
    m_testConfiguration.setSenderDomainResolv();
    m_testConfiguration.setCheckAuthNetworks(true);
    finishSetUp(m_testConfiguration);

    SMTPClient smtpProtocol1 = new SMTPClient();
    smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort);

    assertTrue("first connection taken", smtpProtocol1.isConnected());

    // no message there, yet
    assertNull("no mail received by mail server", queue.getLastMail());

    smtpProtocol1.helo(InetAddress.getLocalHost().toString());

    String sender1 = "[email protected]";
    String sender2 = "[email protected]";

    smtpProtocol1.setSender(sender1);
    assertEquals("expected 501 error", 501, smtpProtocol1.getReplyCode());

    smtpProtocol1.setSender(sender2);

    smtpProtocol1.quit();

}
 
开发者ID:twachan,项目名称:James,代码行数:27,代码来源:SMTPServerTest.java

示例8: testMaxRcptDefault

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
public void testMaxRcptDefault() throws Exception {
    finishSetUp(m_testConfiguration);

    SMTPClient smtpProtocol1 = new SMTPClient();
    smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort);

    smtpProtocol1.helo(InetAddress.getLocalHost().toString());

    String sender1 = "[email protected]";
    String rcpt1 = "[email protected]";

    smtpProtocol1.setSender(sender1);

    smtpProtocol1.addRecipient(rcpt1);

    smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body testMaxRcptDefault\r\n");

    smtpProtocol1.quit();
}
 
开发者ID:twachan,项目名称:James,代码行数:20,代码来源:SMTPServerTest.java

示例9: testHeloEnforcement

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
public void testHeloEnforcement() throws Exception {
    finishSetUp(m_testConfiguration);

    SMTPClient smtpProtocol1 = new SMTPClient();
    smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort);

    assertTrue("first connection taken", smtpProtocol1.isConnected());

    // no message there, yet
    assertNull("no mail received by mail server", queue.getLastMail());

    String sender1 = "[email protected]";
    smtpProtocol1.setSender(sender1);
    assertEquals("expected 503 error", 503, smtpProtocol1.getReplyCode());

    smtpProtocol1.helo(InetAddress.getLocalHost().toString());

    smtpProtocol1.setSender(sender1);

    smtpProtocol1.quit();
}
 
开发者ID:twachan,项目名称:James,代码行数:22,代码来源:SMTPServerTest.java

示例10: testSenderDomainResolvDefault

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
public void testSenderDomainResolvDefault() throws Exception {
    finishSetUp(m_testConfiguration);

    SMTPClient smtpProtocol1 = new SMTPClient();
    smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort);

    smtpProtocol1.helo(InetAddress.getLocalHost().toString());

    String sender1 = "[email protected]";

    smtpProtocol1.setSender(sender1);

    smtpProtocol1.quit();
}
 
开发者ID:twachan,项目名称:James,代码行数:15,代码来源:SMTPServerTest.java

示例11: testMaxRcpt

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
public void testMaxRcpt() throws Exception {
    m_testConfiguration.setMaxRcpt(1);
    finishSetUp(m_testConfiguration);

    SMTPClient smtpProtocol1 = new SMTPClient();
    smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort);

    assertTrue("first connection taken", smtpProtocol1.isConnected());

    // no message there, yet
    assertNull("no mail received by mail server", queue.getLastMail());

    smtpProtocol1.helo(InetAddress.getLocalHost().toString());

    String sender1 = "[email protected]";
    String rcpt1 = "[email protected]";
    String rcpt2 = "[email protected]";

    smtpProtocol1.setSender(sender1);
    smtpProtocol1.addRecipient(rcpt1);

    smtpProtocol1.addRecipient(rcpt2);
    assertEquals("expected 452 error", 452, smtpProtocol1.getReplyCode());

    smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body testMaxRcpt1\r\n");

    // After the data is send the rcpt count is set back to 0.. So a new
    // mail with rcpt should be accepted

    smtpProtocol1.setSender(sender1);

    smtpProtocol1.addRecipient(rcpt1);

    smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body testMaxRcpt2\r\n");

    smtpProtocol1.quit();

}
 
开发者ID:twachan,项目名称:James,代码行数:39,代码来源:SMTPServerTest.java

示例12: testSimpleMailSendWithHELO

import org.apache.commons.net.smtp.SMTPClient; //导入方法依赖的package包/类
/**
 * TODO: Understand why this fails!
 * 
 * public void testEmptyMessage() throws Exception {
 * finishSetUp(m_testConfiguration);
 * 
 * SMTPClient smtp = new SMTPClient(); smtp.connect("127.0.0.1",
 * m_smtpListenerPort);
 * 
 * // no message there, yet assertNull("no mail received by mail server",
 * m_mailServer.getLastMail());
 * 
 * smtp.helo(InetAddress.getLocalHost().toString());
 * 
 * smtp.setSender("[email protected]");
 * 
 * smtp.addRecipient("[email protected]");
 * 
 * smtp.sendShortMessageData("");
 * 
 * smtp.quit();
 * 
 * smtp.disconnect();
 * 
 * // mail was propagated by SMTPServer
 * assertNotNull("mail received by mail server",
 * m_mailServer.getLastMail());
 * 
 * // added to check a NPE in the test (JAMES-474) due to MockMailServer //
 * not cloning the message (added a MimeMessageCopyOnWriteProxy there)
 * System.gc();
 * 
 * int size = queue.getLastMail().getMessage().getSize();
 * 
 * assertEquals(size, 2); }
 */

public void testSimpleMailSendWithHELO() throws Exception {
    finishSetUp(m_testConfiguration);

    SMTPClient smtpProtocol = new SMTPClient();
    smtpProtocol.connect("127.0.0.1", m_smtpListenerPort);

    // no message there, yet
    assertNull("no mail received by mail server", queue.getLastMail());

    smtpProtocol.helo(InetAddress.getLocalHost().toString());

    smtpProtocol.setSender("[email protected]");

    smtpProtocol.addRecipient("[email protected]");

    smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body testSimpleMailSendWithHELO\r\n.\r\n");

    smtpProtocol.quit();
    smtpProtocol.disconnect();

    // mail was propagated by SMTPServer
    assertNotNull("mail received by mail server", queue.getLastMail());
}
 
开发者ID:twachan,项目名称:James,代码行数:61,代码来源:SMTPServerTest.java


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