Author: bago
Date: Mon Apr 3 02:07:57 2006
New Revision: 390984
URL: http://svn.apache.org/viewcvs?rev=390984&view=rev
Log:
Optional check for valid sender domain in mail from (JAMES-465)
Feature implemented by Norman Maurer
Modified:
james/server/trunk/src/conf/james-config.xml
james/server/trunk/src/java/org/apache/james/smtpserver/MailCmdHandler.java
james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java
Modified: james/server/trunk/src/conf/james-config.xml
URL:
http://svn.apache.org/viewcvs/james/server/trunk/src/conf/james-config.xml?rev=390984&r1=390983&r2=390984&view=diff
==============================================================================
--- james/server/trunk/src/conf/james-config.xml (original)
+++ james/server/trunk/src/conf/james-config.xml Mon Apr 3 02:07:57 2006
@@ -719,7 +719,11 @@
<handler command="AUTH"
class="org.apache.james.smtpserver.AuthCmdHandler"></handler>
<handler command="VRFY"
class="org.apache.james.smtpserver.VrfyCmdHandler"></handler>
<handler command="EXPN"
class="org.apache.james.smtpserver.ExpnCmdHandler"></handler>
- <handler command="MAIL"
class="org.apache.james.smtpserver.MailCmdHandler"></handler>
+ <handler command="MAIL"
class="org.apache.james.smtpserver.MailCmdHandler">
+ <!-- If is set to true mail is only accepted if the sender
contains a resolvable domain
+ <checkValidSenderDomain> false </checkValidSenderDomain>
+ -->
+ </handler>
<handler command="RCPT"
class="org.apache.james.smtpserver.RcptCmdHandler"></handler>
<handler command="DATA"
class="org.apache.james.smtpserver.DataCmdHandler"></handler>
<handler command="RSET"
class="org.apache.james.smtpserver.RsetCmdHandler"></handler>
Modified:
james/server/trunk/src/java/org/apache/james/smtpserver/MailCmdHandler.java
URL:
http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/smtpserver/MailCmdHandler.java?rev=390984&r1=390983&r2=390984&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/MailCmdHandler.java
(original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/MailCmdHandler.java
Mon Apr 3 02:07:57 2006
@@ -1,227 +1,277 @@
-/***********************************************************************
- * Copyright (c) 1999-2006 The Apache Software Foundation. *
- * All rights reserved. *
- * ------------------------------------------------------------------- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you *
- * may not use this file except in compliance with the License. You *
- * may obtain a copy of the License at: *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, software *
- * distributed under the License is distributed on an "AS IS" BASIS, *
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
- * implied. See the License for the specific language governing *
- * permissions and limitations under the License. *
- ***********************************************************************/
-
-package org.apache.james.smtpserver;
-
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.james.util.mail.dsn.DSNStatus;
-import org.apache.mailet.MailAddress;
-import java.util.Locale;
-import java.util.StringTokenizer;
-
-/**
- * Handles MAIL command
- */
-public class MailCmdHandler
- extends AbstractLogEnabled
- implements CommandHandler {
-
- private final static String MAIL_OPTION_SIZE = "SIZE";
-
- private final static String MESG_SIZE = "MESG_SIZE"; // The size of the
message
-
- private final static String SENDER = "SENDER_ADDRESS"; // Sender's
email address
-
- /**
- * The helo mode set in state object
- */
- private final static String CURRENT_HELO_MODE = "CURRENT_HELO_MODE"; //
HELO or EHLO
-
- /*
- * handles MAIL command
- *
- * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession)
- **/
- public void onCommand(SMTPSession session) {
- doMAIL(session, session.getCommandArgument());
- }
-
-
- /**
- * Handler method called upon receipt of a MAIL command.
- * Sets up handler to deliver mail as the stated sender.
- *
- * @param session SMTP session object
- * @param argument the argument passed in with the command by the SMTP
client
- */
- private void doMAIL(SMTPSession session, String argument) {
- String responseString = null;
- StringBuffer responseBuffer = session.getResponseBuffer();
-
- String sender = null;
- if ((argument != null) && (argument.indexOf(":") > 0)) {
- int colonIndex = argument.indexOf(":");
- sender = argument.substring(colonIndex + 1);
- argument = argument.substring(0, colonIndex);
- }
- if (session.getState().containsKey(SENDER)) {
- responseString = "503
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" Sender
already specified";
- session.writeResponse(responseString);
- } else if (!session.getState().containsKey(CURRENT_HELO_MODE)) {
- responseString = "503
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" Need HELO
or EHLO before MAIL";
- session.writeResponse(responseString);
- } else if (argument == null ||
!argument.toUpperCase(Locale.US).equals("FROM")
- || sender == null) {
- responseString = "501
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_INVALID_ARG)+"
Usage: MAIL FROM:<sender>";
- session.writeResponse(responseString);
- } else {
- sender = sender.trim();
- // the next gt after the first lt ... AUTH may add more <>
- int lastChar = sender.indexOf('>', sender.indexOf('<'));
- // Check to see if any options are present and, if so, whether
they are correctly formatted
- // (separated from the closing angle bracket by a ' ').
- if ((lastChar > 0) && (sender.length() > lastChar + 2) &&
(sender.charAt(lastChar + 1) == ' ')) {
- String mailOptionString = sender.substring(lastChar + 2);
-
- // Remove the options from the sender
- sender = sender.substring(0, lastChar + 1);
-
- StringTokenizer optionTokenizer = new
StringTokenizer(mailOptionString, " ");
- while (optionTokenizer.hasMoreElements()) {
- String mailOption = optionTokenizer.nextToken();
- int equalIndex = mailOption.indexOf('=');
- String mailOptionName = mailOption;
- String mailOptionValue = "";
- if (equalIndex > 0) {
- mailOptionName = mailOption.substring(0,
equalIndex).toUpperCase(Locale.US);
- mailOptionValue = mailOption.substring(equalIndex + 1);
- }
-
- // Handle the SIZE extension keyword
-
- if (mailOptionName.startsWith(MAIL_OPTION_SIZE)) {
- if (!(doMailSize(session, mailOptionValue, sender))) {
- return;
- }
- } else {
- // Unexpected option attached to the Mail command
- if (getLogger().isDebugEnabled()) {
- StringBuffer debugBuffer =
- new StringBuffer(128)
- .append("MAIL command had
unrecognized/unexpected option ")
- .append(mailOptionName)
- .append(" with value ")
- .append(mailOptionValue);
- getLogger().debug(debugBuffer.toString());
- }
- }
- }
- }
- if (!sender.startsWith("<") || !sender.endsWith(">")) {
- responseString = "501
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.ADDRESS_SYNTAX_SENDER)+"
Syntax error in MAIL command";
- session.writeResponse(responseString);
- if (getLogger().isErrorEnabled()) {
- StringBuffer errorBuffer =
- new StringBuffer(128)
- .append("Error parsing sender address: ")
- .append(sender)
- .append(": did not start and end with < >");
- getLogger().error(errorBuffer.toString());
- }
- return;
- }
- MailAddress senderAddress = null;
- //Remove < and >
- sender = sender.substring(1, sender.length() - 1);
- if (sender.length() == 0) {
- //This is the <> case. Let senderAddress == null
- } else {
- if (sender.indexOf("@") < 0) {
- sender = sender + "@localhost";
- }
- try {
- senderAddress = new MailAddress(sender);
- } catch (Exception pe) {
- responseString = "501
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.ADDRESS_SYNTAX_SENDER)+"
Syntax error in sender address";
- session.writeResponse(responseString);
- if (getLogger().isErrorEnabled()) {
- StringBuffer errorBuffer =
- new StringBuffer(256)
- .append("Error parsing sender address: ")
- .append(sender)
- .append(": ")
- .append(pe.getMessage());
- getLogger().error(errorBuffer.toString());
- }
- return;
- }
- }
- session.getState().put(SENDER, senderAddress);
- responseBuffer.append("250
"+DSNStatus.getStatus(DSNStatus.SUCCESS,DSNStatus.ADDRESS_OTHER)+" Sender <")
- .append(sender)
- .append("> OK");
- responseString = session.clearResponseBuffer();
- session.writeResponse(responseString);
- }
- }
-
- /**
- * Handles the SIZE MAIL option.
- *
- * @param session SMTP session object
- * @param mailOptionValue the option string passed in with the SIZE option
- * @param tempSender the sender specified in this mail command (for
logging purpose)
- * @return true if further options should be processed, false otherwise
- */
- private boolean doMailSize(SMTPSession session, String mailOptionValue,
String tempSender) {
- int size = 0;
- try {
- size = Integer.parseInt(mailOptionValue);
- } catch (NumberFormatException pe) {
- // This is a malformed option value. We return an error
- String responseString = "501
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_INVALID_ARG)+"
Syntactically incorrect value for SIZE parameter";
- session.writeResponse(responseString);
- getLogger().error("Rejected syntactically incorrect value for SIZE
parameter.");
- return false;
- }
- if (getLogger().isDebugEnabled()) {
- StringBuffer debugBuffer =
- new StringBuffer(128)
- .append("MAIL command option SIZE received with value ")
- .append(size)
- .append(".");
- getLogger().debug(debugBuffer.toString());
- }
- long maxMessageSize =
session.getConfigurationData().getMaxMessageSize();
- if ((maxMessageSize > 0) && (size > maxMessageSize)) {
- // Let the client know that the size limit has been hit.
- String responseString = "552
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SYSTEM_MSG_TOO_BIG)+"
Message size exceeds fixed maximum message size";
- session.writeResponse(responseString);
- StringBuffer errorBuffer =
- new StringBuffer(256)
- .append("Rejected message from ")
- .append(tempSender != null ? tempSender.toString() : null)
- .append(" from host ")
- .append(session.getRemoteHost())
- .append(" (")
- .append(session.getRemoteIPAddress())
- .append(") of size ")
- .append(size)
- .append(" exceeding system maximum message size of ")
- .append(maxMessageSize)
- .append("based on SIZE option.");
- getLogger().error(errorBuffer.toString());
- return false;
- } else {
- // put the message size in the message state so it can be used
- // later to restrict messages for user quotas, etc.
- session.getState().put(MESG_SIZE, new Integer(size));
- }
- return true;
- }
-
-}
+/***********************************************************************
+ * Copyright (c) 1999-2006 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you *
+ * may not use this file except in compliance with the License. You *
+ * may obtain a copy of the License at: *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, *
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
+ * implied. See the License for the specific language governing *
+ * permissions and limitations under the License. *
+ ***********************************************************************/
+
+package org.apache.james.smtpserver;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.james.util.mail.dsn.DSNStatus;
+import org.apache.mailet.MailAddress;
+import org.xbill.DNS.Lookup;
+import org.xbill.DNS.Record;
+import org.xbill.DNS.TextParseException;
+import org.xbill.DNS.Type;
+
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+/**
+ * Handles MAIL command
+ */
+public class MailCmdHandler
+ extends AbstractLogEnabled
+ implements CommandHandler,Configurable {
+
+ private final static String MAIL_OPTION_SIZE = "SIZE";
+
+ private final static String MESG_SIZE = "MESG_SIZE"; // The size of the
message
+
+ private final static String SENDER = "SENDER_ADDRESS"; // Sender's
email address
+
+ /**
+ * The helo mode set in state object
+ */
+ private final static String CURRENT_HELO_MODE = "CURRENT_HELO_MODE"; //
HELO or EHLO
+
+ private boolean checkValidSenderDomain = false;
+
+ /**
+ * @see
org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
+ */
+ public void configure(Configuration handlerConfiguration) throws
ConfigurationException {
+ Configuration configuration =
handlerConfiguration.getChild("checkValidSenderDomain",false);
+ if(configuration != null) {
+ checkValidSenderDomain = configuration.getValueAsBoolean();
+ }
+ }
+
+ /*
+ * handles MAIL command
+ *
+ * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession)
+ **/
+ public void onCommand(SMTPSession session) {
+ doMAIL(session, session.getCommandArgument());
+ }
+
+
+ /**
+ * Handler method called upon receipt of a MAIL command.
+ * Sets up handler to deliver mail as the stated sender.
+ *
+ * @param session SMTP session object
+ * @param argument the argument passed in with the command by the SMTP
client
+ */
+ private void doMAIL(SMTPSession session, String argument) {
+ String responseString = null;
+ StringBuffer responseBuffer = session.getResponseBuffer();
+ String sender = null;
+ boolean badSenderDomain = false;
+
+ if ((argument != null) && (argument.indexOf(":") > 0)) {
+ int colonIndex = argument.indexOf(":");
+ sender = argument.substring(colonIndex + 1);
+ argument = argument.substring(0, colonIndex);
+ }
+ if (session.getState().containsKey(SENDER)) {
+ responseString = "503
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" Sender
already specified";
+ session.writeResponse(responseString);
+ } else if (!session.getState().containsKey(CURRENT_HELO_MODE)) {
+ responseString = "503
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" Need HELO
or EHLO before MAIL";
+ session.writeResponse(responseString);
+ } else if (argument == null ||
!argument.toUpperCase(Locale.US).equals("FROM")
+ || sender == null) {
+ responseString = "501
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_INVALID_ARG)+"
Usage: MAIL FROM:<sender>";
+ session.writeResponse(responseString);
+ } else {
+ sender = sender.trim();
+ // the next gt after the first lt ... AUTH may add more <>
+ int lastChar = sender.indexOf('>', sender.indexOf('<'));
+ // Check to see if any options are present and, if so, whether
they are correctly formatted
+ // (separated from the closing angle bracket by a ' ').
+ if ((lastChar > 0) && (sender.length() > lastChar + 2) &&
(sender.charAt(lastChar + 1) == ' ')) {
+ String mailOptionString = sender.substring(lastChar + 2);
+
+ // Remove the options from the sender
+ sender = sender.substring(0, lastChar + 1);
+
+ StringTokenizer optionTokenizer = new
StringTokenizer(mailOptionString, " ");
+ while (optionTokenizer.hasMoreElements()) {
+ String mailOption = optionTokenizer.nextToken();
+ int equalIndex = mailOption.indexOf('=');
+ String mailOptionName = mailOption;
+ String mailOptionValue = "";
+ if (equalIndex > 0) {
+ mailOptionName = mailOption.substring(0,
equalIndex).toUpperCase(Locale.US);
+ mailOptionValue = mailOption.substring(equalIndex + 1);
+ }
+
+ // Handle the SIZE extension keyword
+
+ if (mailOptionName.startsWith(MAIL_OPTION_SIZE)) {
+ if (!(doMailSize(session, mailOptionValue, sender))) {
+ return;
+ }
+ } else {
+ // Unexpected option attached to the Mail command
+ if (getLogger().isDebugEnabled()) {
+ StringBuffer debugBuffer =
+ new StringBuffer(128)
+ .append("MAIL command had
unrecognized/unexpected option ")
+ .append(mailOptionName)
+ .append(" with value ")
+ .append(mailOptionValue);
+ getLogger().debug(debugBuffer.toString());
+ }
+ }
+ }
+ }
+ if (!sender.startsWith("<") || !sender.endsWith(">")) {
+ responseString = "501
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.ADDRESS_SYNTAX_SENDER)+"
Syntax error in MAIL command";
+ session.writeResponse(responseString);
+ if (getLogger().isErrorEnabled()) {
+ StringBuffer errorBuffer =
+ new StringBuffer(128)
+ .append("Error parsing sender address: ")
+ .append(sender)
+ .append(": did not start and end with < >");
+ getLogger().error(errorBuffer.toString());
+ }
+ return;
+ }
+ MailAddress senderAddress = null;
+ //Remove < and >
+ sender = sender.substring(1, sender.length() - 1);
+ if (sender.length() == 0) {
+ //This is the <> case. Let senderAddress == null
+ } else {
+
+ if (sender.indexOf("@") < 0) {
+ sender = sender + "@localhost";
+ }
+
+ try {
+ senderAddress = new MailAddress(sender);
+ } catch (Exception pe) {
+ responseString = "501
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.ADDRESS_SYNTAX_SENDER)+"
Syntax error in sender address";
+ session.writeResponse(responseString);
+ if (getLogger().isErrorEnabled()) {
+ StringBuffer errorBuffer =
+ new StringBuffer(256)
+ .append("Error parsing sender address: ")
+ .append(sender)
+ .append(": ")
+ .append(pe.getMessage());
+ getLogger().error(errorBuffer.toString());
+ }
+ return;
+ }
+ }
+
+ if (checkValidSenderDomain == true) {
+
+ // Maybe we should build a static method in
org.apache.james.dnsserver.DNSServer ?
+ Record[] records;
+
+ try {
+ records = new Lookup(senderAddress.getHost(),
Type.MX).run();
+ getLogger().info("rec: "+ records);
+ if (records == null) {
+ badSenderDomain = true;
+ }
+ } catch (TextParseException e) {
+ // no validdomain
+ badSenderDomain = true;
+ }
+
+ // try to resolv the provided domain in the senderaddress. If
it can not resolved do not accept it.
+ if (badSenderDomain) {
+ responseString = "501
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.ADDRESS_SYNTAX_SENDER)+ "
sender " + senderAddress + " contains no valid domain";
+ session.writeResponse(responseString);
+ getLogger().info(responseString);
+ }
+ }
+
+ if (!badSenderDomain) {
+ session.getState().put(SENDER, senderAddress);
+ responseBuffer.append("250
"+DSNStatus.getStatus(DSNStatus.SUCCESS,DSNStatus.ADDRESS_OTHER)+" Sender <")
+ .append(sender)
+ .append("> OK");
+ responseString = session.clearResponseBuffer();
+ session.writeResponse(responseString);
+ }
+ }
+ }
+
+ /**
+ * Handles the SIZE MAIL option.
+ *
+ * @param session SMTP session object
+ * @param mailOptionValue the option string passed in with the SIZE option
+ * @param tempSender the sender specified in this mail command (for
logging purpose)
+ * @return true if further options should be processed, false otherwise
+ */
+ private boolean doMailSize(SMTPSession session, String mailOptionValue,
String tempSender) {
+ int size = 0;
+ try {
+ size = Integer.parseInt(mailOptionValue);
+ } catch (NumberFormatException pe) {
+ // This is a malformed option value. We return an error
+ String responseString = "501
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_INVALID_ARG)+"
Syntactically incorrect value for SIZE parameter";
+ session.writeResponse(responseString);
+ getLogger().error("Rejected syntactically incorrect value for SIZE
parameter.");
+ return false;
+ }
+ if (getLogger().isDebugEnabled()) {
+ StringBuffer debugBuffer =
+ new StringBuffer(128)
+ .append("MAIL command option SIZE received with value ")
+ .append(size)
+ .append(".");
+ getLogger().debug(debugBuffer.toString());
+ }
+ long maxMessageSize =
session.getConfigurationData().getMaxMessageSize();
+ if ((maxMessageSize > 0) && (size > maxMessageSize)) {
+ // Let the client know that the size limit has been hit.
+ String responseString = "552
"+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SYSTEM_MSG_TOO_BIG)+"
Message size exceeds fixed maximum message size";
+ session.writeResponse(responseString);
+ StringBuffer errorBuffer =
+ new StringBuffer(256)
+ .append("Rejected message from ")
+ .append(tempSender != null ? tempSender.toString() : null)
+ .append(" from host ")
+ .append(session.getRemoteHost())
+ .append(" (")
+ .append(session.getRemoteIPAddress())
+ .append(") of size ")
+ .append(size)
+ .append(" exceeding system maximum message size of ")
+ .append(maxMessageSize)
+ .append("based on SIZE option.");
+ getLogger().error(errorBuffer.toString());
+ return false;
+ } else {
+ // put the message size in the message state so it can be used
+ // later to restrict messages for user quotas, etc.
+ session.getState().put(MESG_SIZE, new Integer(size));
+ }
+ return true;
+ }
+
+}
Modified:
james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
URL:
http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java?rev=390984&r1=390983&r2=390984&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
(original)
+++ james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
Mon Apr 3 02:07:57 2006
@@ -310,6 +310,52 @@
smtpProtocol1.quit();
}
+ public void testSenderDomainResolv() throws Exception, SMTPException {
+ m_testConfiguration.setSenderDomainResolv();
+ finishSetUp(m_testConfiguration);
+
+
+ SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1",
m_smtpListenerPort);
+ smtpProtocol1.openPort();
+
+ assertEquals("first connection taken", 1, smtpProtocol1.getState());
+
+ // no message there, yet
+ assertNull("no mail received by mail server",
m_mailServer.getLastMail());
+
+ smtpProtocol1.helo(InetAddress.getLocalHost());
+
+ String sender1 = "[EMAIL PROTECTED]";
+ String sender2 = "[EMAIL PROTECTED]";
+
+ try {
+ smtpProtocol1.mail(new Address(sender1));
+ fail("sender should not accept");
+ } catch (SMTPException e) {
+ assertEquals("expected 501 error", 501, e.getCode());
+ }
+
+ smtpProtocol1.mail(new Address(sender2));
+
+ smtpProtocol1.quit();
+
+ }
+
+ public void testSenderDomainResolvDefault() throws Exception,
SMTPException {
+ finishSetUp(m_testConfiguration);
+
+ SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1",
m_smtpListenerPort);
+ smtpProtocol1.openPort();
+
+ smtpProtocol1.helo(InetAddress.getLocalHost());
+
+ String sender1 = "[EMAIL PROTECTED]";
+
+ smtpProtocol1.mail(new Address(sender1));
+
+ smtpProtocol1.quit();
+ }
+
public void testEhloResolv() throws Exception, SMTPException {
m_testConfiguration.setEhloResolv();
finishSetUp(m_testConfiguration);
@@ -326,7 +372,7 @@
String[] ehlo1 = new String[] { "abgsfe3rsf.de"};
String[] ehlo2 = new String[] { "james.apache.org" };
- smtpProtocol1.sendCommand("ehlo",ehlo1);
+ smtpProtocol1.sendCommand("ehlo", ehlo1);
SMTPResponse response = smtpProtocol1.getResponse();
// this should give a 501 code cause the ehlo could not resolved
assertEquals("expected error: ehlo could not resolved", 501,
response.getCode());
@@ -394,12 +440,12 @@
String userName = "test_user_smtp";
String noexistUserName = "noexist_test_user_smtp";
-
+ String sender ="[EMAIL PROTECTED]";
smtpProtocol.sendCommand("AUTH FOO", null);
SMTPResponse response = smtpProtocol.getResponse();
assertEquals("expected error: unrecognized authentication type", 504,
response.getCode());
- smtpProtocol.mail(new Address(userName));
+ smtpProtocol.mail(new Address(sender));
try {
smtpProtocol.rcpt(new Address("[EMAIL PROTECTED]"));
Modified:
james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java
URL:
http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java?rev=390984&r1=390983&r2=390984&view=diff
==============================================================================
---
james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java
(original)
+++
james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java
Mon Apr 3 02:07:57 2006
@@ -33,6 +33,7 @@
private Integer m_connectionLimit = null;
private boolean m_heloResolv = false;
private boolean m_ehloResolv = false;
+ private boolean m_senderDomainResolv = false;
public SMTPTestConfiguration(int smtpListenerPort) {
super("smptserver");
@@ -83,6 +84,10 @@
public void setEhloResolv() {
m_ehloResolv = true;
}
+
+ public void setSenderDomainResolv() {
+ m_senderDomainResolv = true;
+ }
public void init() throws ConfigurationException {
@@ -110,7 +115,10 @@
((DefaultConfiguration)
heloConfig[i]).addChild(Util.getValuedConfiguration("checkValidHelo",m_heloResolv+""));
} else if ("EHLO".equals(cmd)) {
((DefaultConfiguration)
heloConfig[i]).addChild(Util.getValuedConfiguration("checkValidEhlo",m_ehloResolv+""));
+ } else if ("MAIL".equals(cmd)) {
+ ((DefaultConfiguration)
heloConfig[i]).addChild(Util.getValuedConfiguration("checkValidSenderDomain",m_senderDomainResolv+""));
}
+
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]