# Path: Milter/utils.py
# def parse_addr(t):
#   """Split email into user,domain.
# 
#   >>> parse_addr('user@example.com')
#   ['user', 'example.com']
#   >>> parse_addr('"user@example.com"')
#   ['user@example.com']
#   >>> parse_addr('"user@bar"@example.com')
#   ['user@bar', 'example.com']
#   >>> parse_addr('foo')
#   ['foo']
#   >>> parse_addr('@mx.example.com:user@example.com')
#   ['user', 'example.com']
#   >>> parse_addr('@user@example.com')
#   ['@user', 'example.com']
#   """
#   if t.startswith('<') and t.endswith('>'): t = t[1:-1]
#   if t.startswith('"'):
#     if t.endswith('"'): return [t[1:-1]]
#     pos = t.find('"@')
#     if pos > 0: return [t[1:pos],t[pos+2:]]
#   if t.startswith('@'):
#     try: t = t.split(':',1)[1]
#     except IndexError: pass
#   return t.rsplit('@',1)


import Milter
import time
import sys
from Milter.utils import parse_addr
    # Num internals
    num_internal_hosts = hostnames_mapped.count(True)

    # Num externals
    num_external_hosts = hostnames_mapped.count(False)

    return num_external_hosts >= 1 and num_internal_hosts >= 1

class NoMixMilter(Milter.Base):

  def __init__(self):  # A new instance with each new connection.
    self.id = Milter.uniqueID()  # Integer incremented with each call.


  ##  def envfrom(self,f,*str):
  @Milter.noreply
  def envfrom(self, mailfrom, *str):
    self.mailfrom = mailfrom
    self.domains = []
    t = parse_addr(mailfrom)
    if len(t) > 1:
      self.domains.append(t[1])
    else:
      self.domains.append('local')
    self.internal = False
    return Milter.CONTINUE

  ##  def envrcpt(self, to, *str):
  def envrcpt(self, to, *str):
    self.R.append(to)

# Path: Milter/utils.py
# def parse_addr(t):
#   """Split email into user,domain.
# 
#   >>> parse_addr('user@example.com')
#   ['user', 'example.com']
#   >>> parse_addr('"user@example.com"')
#   ['user@example.com']
#   >>> parse_addr('"user@bar"@example.com')
#   ['user@bar', 'example.com']
#   >>> parse_addr('foo')
#   ['foo']
#   >>> parse_addr('@mx.example.com:user@example.com')
#   ['user', 'example.com']
#   >>> parse_addr('@user@example.com')
#   ['@user', 'example.com']
#   """
#   if t.startswith('<') and t.endswith('>'): t = t[1:-1]
#   if t.startswith('"'):
#     if t.endswith('"'): return [t[1:-1]]
#     pos = t.find('"@')
#     if pos > 0: return [t[1:pos],t[pos+2:]]
#   if t.startswith('@'):
#     try: t = t.split(':',1)[1]
#     except IndexError: pass
#   return t.rsplit('@',1)


# Path: milter-nomix.py
import Milter
import time
import sys
from Milter.utils import parse_addr

    # Num internals
    num_internal_hosts = hostnames_mapped.count(True)

    # Num externals
    num_external_hosts = hostnames_mapped.count(False)

    return num_external_hosts >= 1 and num_internal_hosts >= 1

class NoMixMilter(Milter.Base):

  def __init__(self):  # A new instance with each new connection.
    self.id = Milter.uniqueID()  # Integer incremented with each call.


  ##  def envfrom(self,f,*str):
  @Milter.noreply
  def envfrom(self, mailfrom, *str):
    self.mailfrom = mailfrom
    self.domains = []
    t = parse_addr(mailfrom)
    if len(t) > 1:
      self.domains.append(t[1])
    else:
      self.domains.append('local')
    self.internal = False
    return Milter.CONTINUE

  ##  def envrcpt(self, to, *str):
  def envrcpt(self, to, *str):
    self.R.append(to)

    t = parse_addr(to)