Package org.subethamail.smtp.server

Examples of org.subethamail.smtp.server.Session


  }

  @Override
  public void execute(String commandString, ConnectionContext context) throws IOException
  {
    Session session = context.getSession();

    if (!session.getHasSender())
    {
      context.sendResponse("503 Error: need MAIL command");
      return;
    }
    else if (session.getRecipientCount() == 0)
    {
      context.sendResponse("503 Error: need RCPT command");
      return;
    }

    context.sendResponse("354 End data with <CR><LF>.<CR><LF>");
    session.setDataMode(true);
  }
View Full Code Here


  }

  @Override
  public void execute(String commandString, ConnectionContext context) throws IOException
  {
    Session session = context.getSession();
    session.reset(true);

    context.sendResponse("250 Ok");
  }
View Full Code Here

  }

  @Override
  public void execute(String commandString, ConnectionContext context) throws IOException
  {
    Session session = context.getSession();

    InputStream stream = context.getInput().getInputStream();
   
    stream = new CharTerminatedInputStream(stream, SMTP_TERMINATOR);
    stream = new DotUnstuffingInputStream(stream);

    try
    {
      session.getMessageHandler().data(stream);
      context.sendResponse("250 Ok");
    }
    catch (RejectException ex)
    {
      context.sendResponse(ex.getMessage());
    }

    session.reset(true); // reset session, but don't require new HELO/EHLO
  }
View Full Code Here

    {
      context.sendResponse("501 Syntax: HELO <hostname>");
      return;
    }

    Session session = context.getSession();
    session.setHasSeenHelo(true);
    context.sendResponse("250 " + context.getSMTPServer().getHostName());
  }
View Full Code Here

  }

  @Override
  public void execute(String commandString, ConnectionContext context) throws IOException
  {
    Session session = context.getSession();
    if (!session.getHasSeenHelo())
    {
      context.sendResponse("503 Error: send HELO/EHLO first");
    }
    else if (session.getHasSender())
    {
      context.sendResponse("503 Sender already specified.");
    }
    else
    {
      if (commandString.trim().equals("MAIL FROM:"))
      {
        context.sendResponse("501 Syntax: MAIL FROM: <address>");
        return;
      }

      String args = getArgPredicate(commandString);
      if (!args.toUpperCase().startsWith("FROM:"))
      {
        context.sendResponse("501 Syntax: MAIL FROM: <address>  Error in parameters: \""
                + getArgPredicate(commandString) + "\"");
        return;
      }

      String emailAddress = extractEmailAddress(args, 5);
      if (isValidEmailAddress(emailAddress))
      {
        try
        {
          session.getMessageHandler().from(emailAddress);
          session.setHasSender(true);
          context.sendResponse("250 Ok");
        }
        catch (RejectException ex)
        {
          context.sendResponse(ex.getMessage());
View Full Code Here

  }

  @Override
  public void execute(String commandString, ConnectionContext context) throws IOException
  {
    Session session = context.getSession();
    if (!session.getHasSender())
    {
      context.sendResponse("503 Error: need MAIL command");
      return;
    }
    else if (context.getSMTPServer().getMaxRecipients() > -1 &&
        session.getRecipientCount() >= context.getSMTPServer().getMaxRecipients())
    {
      context.sendResponse("452 Error: too many recipients");
      return;
    }

    String args = getArgPredicate(commandString);
    if (!args.toUpperCase().startsWith("TO:"))
    {
      context.sendResponse("501 Syntax: RCPT TO: <address>  Error in parameters: \"" + args + "\"");
      return;
    }
    else
    {
      String recipientAddress = extractEmailAddress(args, 3);
      try
      {
        session.getMessageHandler().recipient(recipientAddress);
        session.addRecipient();
        context.sendResponse("250 Ok");
      }
      catch (RejectException ex)
      {
        context.sendResponse(ex.getMessage());
View Full Code Here

TOP

Related Classes of org.subethamail.smtp.server.Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.