sending mail cc, bcc

Gerrit Holl gerrit at nl.linux.org
Thu Jan 29 10:31:02 EST 2004


Alberto Vera wrote:
> I have a library called smtplib that send email
> I use these lines to use it:  (from -->to)
> ------------------------------------
> server = smtplib.SMTP(server)
> server.sendmail(fromaddr, toaddrs, message)
> ------------------------------------
> 
> But I'd like to include some mails CC ,BCC.
> (from -->to)
> (       |-->cc )
> (       |-->bcc)
> 
> Does anyone have a library to make it? (mail: from, to, cc, bcc)

The 'message' string contains the headers. The information in this
string is not used to determine the recipients. So, you can do:

message = "From: Knight who says Ni <knight42 at ni.int>
To: Sir Galahad <galahad at brave.uk>
Cc: Sir Robin <robin at brave.uk>

Ni!
"""

...while you send it to someone else in reality:

server.sendmail("my at address.com", ["mother at isp.com", "father at isp.com"], message)

See also the online documentation.
Try it out!

yours,
Gerrit.

-- 
243. As rent of herd cattle he shall pay three gur of corn to the
owner.
          -- 1780 BC, Hammurabi, Code of Law
-- 
PrePEP: Builtin path type
    http://people.nl.linux.org/~gerrit/creaties/path/pep-xxxx.html
Asperger's Syndrome - a personal approach:
	http://people.nl.linux.org/~gerrit/english/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20040129/d62bc0ba/attachment.sig>


More information about the Python-list mailing list