Skip to content

Instantly share code, notes, and snippets.

@emberian
Forked from anonymous/mail_gen
Created June 18, 2012 17:37
Show Gist options
  • Save emberian/2949594 to your computer and use it in GitHub Desktop.
Save emberian/2949594 to your computer and use it in GitHub Desktop.
>>> def generate(startdate, recipients, daycount, message):
... last_date = startdate
... mail = email.message_from_string(message)
... msg_lib = []
... for i in range(0, daycount):
... for recep in range(len(recipients)):
... mail['date'] = email.utils.formatdate(time.mktime(last_date.utctimetuple()))
... msg_lib.append(mail)
... last_date = last_date + datetime.timedelta(days=1)
... return msg_lib
...
...
>>> f = generate(datetime.datetime.now(), ['me', 'you'], 4, "Hello!")
>>> from itertools import product
>>> g = product(f, repeat=2)
>>> all(x is y for x, y in g)
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment