Opened 15 years ago

Last modified 3 years ago

#540 defect closed fixed (fixed)

SMTPSenderFactory has unintended side effect

Reported by: mjs Owned by:
Priority: high Milestone:
Component: mail Keywords:
Cc: Jean-Paul Calderone, spiv, mjs Branch:
Author:

Description


Change History (4)

comment:1 Changed 15 years ago by mjs

SMTPSenderFactory uses and modifies its toEmail argument directly without making
a copy first. This can have some unexpected side effects when using a constant
list of recipients as input.

eg.
from twisted.protocols import smtp
from twisted.internet import reactor

FROM_ADDR = 'from@domain.com'
TO_ADDRS = ['rcpt1@domain.com', 'rcpt2@domain.com']
TO_HOST = 'x.x.x.x'

def sendsomething():
    smtp.sendmail(TO_HOST, FROM_ADDR, TO_ADDRS, 'fooo')

sendsomething()
reactor.callLater(10, sendsomething)
reactor.run()

---

When the second call to sendsomething() occurs TO_ADDRS == [] and the email will
not be sent as intended (no recipients specified).

Workaround is to always copy TO_ADDRS before calling smtp.sendmail() but the
side-effect is not obvious and may not always be noticed.

comment:2 Changed 15 years ago by Jean-Paul Calderone

Resolved in r11825.  smtp.py now iterates over the to addresses, instead of
popping from the list.

comment:3 Changed 9 years ago by <automation>

Owner: Jean-Paul Calderone deleted

comment:4 Changed 3 years ago by Craig Rodrigues <rodrigc@…>

In 01611cba:

Merge pull request #540 from twisted/8079-no-gmpy

Author: hawkowl
Reviewer: rodrigc
Fixes: #8079

Remove gmpy support

Note: See TracTickets for help on using tickets.