Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add env_sender parameter to forward and forward_copy methods

  • Loading branch information...
commit 3b70a081822d1df44989ee67fe9d5d298c740273 1 parent 9697a5a
Joel Rosdahl authored
Showing with 39 additions and 17 deletions.
  1. +4 −0 NEWS
  2. +4 −0 doc/examples/sketchy.rc
  3. +11 −5 doc/reference.html
  4. +20 −12 maildirproc
4 NEWS
View
@@ -1,3 +1,7 @@
+Unreleased
+
+ - Added env_sender parameter to forward and forward_copy methods.
+
Version 0.5.0 (2010-10-31)
- maildirproc is now a Python 3.x project. Install maildirproc-python2 for
4 doc/examples/sketchy.rc
View
@@ -65,3 +65,7 @@ for mail in processor:
# Forward the mail to external recipients AND DELETE THE MAIL.
mail.forward("address@example.com")
mail.forward(["address1@example.com", "address2@example.com"])
+
+ # Forward a copy of the mail and explicitly set the envelope sender
+ # address.
+ mail.forward_copy("address@example.com", "envelope@example.com")
16 doc/reference.html
View
@@ -178,11 +178,17 @@
<dt>delete()</dt>
<dd>Delete the mail.</dd>
-<dt>forward(<i>addresses</i>)</dt>
-<dd>Forward the mail to one or several e-mail addresses <b>and delete the mail</b>. <i>addresses</i> can be either a string or a list of strings.</dd>
-
-<dt>forward_copy(<i>addresses</i>)</dt>
-<dd>Forward a copy of the mail to one or several e-mail addresses. <i>addresses</i> can be either a string or a list of strings.</dd>
+<dt>forward(<i>addresses[, env_sender]</i>)</dt>
+<dd>Forward the mail to one or several e-mail addresses <b>and delete the
+mail</b>. <i>addresses</i> can be either a string or a list of
+strings. <i>env_sender</i> (optional) specifies which envelope sender address
+to use.</dd>
+
+<dt>forward_copy(<i>addresses[, env_sender]</i>)</dt>
+<dd>Forward a copy of the mail to one or several e-mail
+addresses. <i>addresses</i> can be either a string or a list of
+strings. <i>env_sender</i> (optional) specifies which envelope sender address
+to use.</dd>
<dt>from_mailing_list(<i>list</i>)</dt>
<dd>Check whether the mail originated from the mailing list
32 maildirproc
View
@@ -280,18 +280,18 @@ class DryRunMail(MailBase):
def delete(self):
self._processor.log("==> Deleting")
- def forward(self, addresses):
- self._forward(True, addresses)
+ def forward(self, addresses, env_sender=None):
+ self._forward(True, addresses, env_sender)
- def forward_copy(self, addresses):
- self._forward(False, addresses)
+ def forward_copy(self, addresses, env_sender=None):
+ self._forward(False, addresses, env_sender)
def move(self, maildir):
self._processor.log("==> Moving to {0}".format(maildir))
# ----------------------------------------------------------------
- def _forward(self, delete, addresses):
+ def _forward(self, delete, addresses, env_sender):
if isinstance(addresses, basestring):
addresses = [addresses]
else:
@@ -301,7 +301,11 @@ class DryRunMail(MailBase):
else:
copy = ""
self._processor.log(
- "==> Forwarding{0} to {1!r}".format(copy, addresses))
+ "==> Forwarding{0} to {1!r}{2}".format(
+ copy,
+ addresses,
+ " (envelope sender: {0}".format(env_sender)
+ if env_sender is not None else ""))
class Mail(MailBase):
@@ -313,11 +317,11 @@ class Mail(MailBase):
self._processor.log("==> Deleting")
self._delete()
- def forward(self, addresses):
- self._forward(True, addresses)
+ def forward(self, addresses, env_sender=None):
+ self._forward(True, addresses, env_sender)
- def forward_copy(self, addresses):
- self._forward(False, addresses)
+ def forward_copy(self, addresses, env_sender=None):
+ self._forward(False, addresses, env_sender)
def move(self, maildir):
self._processor.log("==> Moving to {0}".format(maildir))
@@ -386,7 +390,7 @@ class Mail(MailBase):
" it".format(self.path),
e)
- def _forward(self, delete, addresses):
+ def _forward(self, delete, addresses, env_sender):
if isinstance(addresses, basestring):
addresses = [addresses]
else:
@@ -395,6 +399,10 @@ class Mail(MailBase):
copy = ""
else:
copy = " copy"
+ flags = self._processor.sendmail_flags
+ if env_sender is not None:
+ flags += " -f {0}".format(env_sender)
+
self._processor.log("==> Forwarding{0} to {1!r}".format(copy, addresses))
try:
source_fp = open(self.path, "rb")
@@ -406,7 +414,7 @@ class Mail(MailBase):
p = subprocess.Popen(
"{0} {1} -- {2}".format(
self._processor.sendmail,
- self._processor.sendmail_flags,
+ flags,
" ".join(addresses)
),
shell=True,
Please sign in to comment.
Something went wrong with that request. Please try again.