Esempio n. 1
0
 def splitRecipientsLocalRemote(self, recipients):
     localrecipients = []
     remoterecipients = []
     for recipient in recipients:
         if isLocalAddress(recipient, self.localdict):
             localrecipients.append(recipient)
         else:
             remoterecipients.append(recipient)
     return (localrecipients, remoterecipients)
Esempio n. 2
0
    def stateGetRecipients(self, msg):
        splitmsg = msg.split(" ", 1)
        command = splitmsg[0].upper()

        if command == "VRFY":
            self.send("252 send some mail, i'll try my best\r\n", "outbox")

        elif command == "NOOP":
            self.send("250 utterly pointless\r\n", "outbox")

        elif command == "RSET":
            self.send("250 Ok\r\n", "outbox")
            self.sendToMailStorage(MIPCCancelLastUnfinishedMessage())
            return self.stateGetMailFrom

        elif command == "DATA":
            if self.recipientcount == 0:
                self.send("503 need RCPT before DATA\r\n", "outbox")
            else:
                self.send("354 End data with <CR><LF>.<CR><LF>\r\n", "outbox")
                return self.stateGetData

        elif command == "RCPT":
            if len(splitmsg) == 2:
                if splitmsg[1][:3].upper() == "TO:":
                    toemail = splitmsg[1][3:].strip()
                    if toemail[:1] == "<" and toemail[-1:] == ">":
                        toemail = toemail[1:-1].strip()

                    if not isLocalAddress(toemail, self.localdict):
                        self.send(
                            "553 we don't relay mail to remote addresses\r\n",
                            "outbox")
                    else:
                        self.recipientcount += 1
                        self.sendToMailStorage(
                            MIPCNewRecipient(recipientemail=toemail))
                        self.send("250 OK\r\n", "outbox")
                else:
                    self.send(
                        "501 Syntax error in parameters or arguments\r\n",
                        "outbox")
            else:
                self.send("501 Syntax error in parameters or arguments\r\n",
                          "outbox")
        else:
            self.send("500 Unrecognised command\r\n", "outbox")
Esempio n. 3
0
 def stateGetRecipients(self, msg):
     splitmsg = msg.split(" ", 1)
     command = splitmsg[0].upper()
     
     if command == "VRFY":
         self.send("252 send some mail, i'll try my best\r\n", "outbox")
         
     elif command == "NOOP":
         self.send("250 utterly pointless\r\n", "outbox")        
         
     elif command == "RSET":
         self.send("250 Ok\r\n", "outbox")
         self.sendToMailStorage(MIPCCancelLastUnfinishedMessage())
         return self.stateGetMailFrom
         
     elif command == "DATA":
         if self.recipientcount == 0:
             self.send("503 need RCPT before DATA\r\n", "outbox")
         else:
             self.send("354 End data with <CR><LF>.<CR><LF>\r\n", "outbox")
             return self.stateGetData
             
     elif command == "RCPT":
         if len(splitmsg) == 2:
             if splitmsg[1][:3].upper() == "TO:":
                 toemail = splitmsg[1][3:].strip()
                 if toemail[:1] == "<" and toemail[-1:] == ">":
                     toemail = toemail[1:-1].strip()
                     
                 if not isLocalAddress(toemail, self.localdict):
                      self.send("553 we don't relay mail to remote addresses\r\n", "outbox")
                 else:
                     self.recipientcount += 1
                     self.sendToMailStorage(MIPCNewRecipient(recipientemail=toemail))
                     self.send("250 OK\r\n", "outbox")
             else:
                 self.send("501 Syntax error in parameters or arguments\r\n", "outbox")
         else:
             self.send("501 Syntax error in parameters or arguments\r\n", "outbox")
     else:
         self.send("500 Unrecognised command\r\n", "outbox")