本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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());
}