On Fri, 30 Nov 2012 12:25:37 -0800 (PST), Ed <>
declaimed the following in gmane.comp.python.general:
> # Start the server:
> smtp.ehlo()
>
Technically, the server is always running -- this just connects you
(as a CLIENT) to that running server.
> # Send the email
> smtp.sendmail(sender, [to] + bcc, msg.as_string())
I notice that you left OUT the CC addresses.
>
> The above generates the following error:
> Traceback (most recent call last):
> File "/opt/batch/ebtest/example4.py", line 46, in <module>
> smtp.sendmail(sender, [to] + bcc, msg.as_string())
Pardon --- you failed to include the ERROR, you've only supplied the
traceback identifying which line failed.
However, presuming the error is
TypeError: can only concatenate list (not "str") to list
then the solution is obvious... DON'T try to use "+" with a string on
one side and a list on the other...
>>> [to] + [cc] + [bcc]
['', '', '']
But note that this won't work if one of the three is already a list!
>>> bcc = ["", "someone.else"]
>>> [to] + [cc] + [bcc]
['', '', ['', 'someone.else']]
If you ensure that each address block starts as a list, you can...
>>> to = [""]
>>> cc = [""]
>>> bcc = ["", "someone.else"]
>>> add = []
>>> add.extend(to)
>>> add.extend(cc)
>>> add.extend(bcc)
>>> add
['', '', '', 'someone.else']
>>>
--
Wulfraed Dennis Lee Bieber AF6VN
HTTP://wlfraed.home.netcom.com/