STMP, mail, sender-from, to-bcc-addr

D

durumdara

Hi!

I wanna ask that have anyone some experience with email.msg and smtplib?

The email message and smtp.send already have "sender/from" and
"recip/addr to".
Possible the smtp components does not uses the email tags if I not
define them only in the message?

Can I do same thing as in GMAIL that the mail does not have TO, only BCC
tags/recipients, and no one of the recipients who knows about the each
others?

Thanks:
dd
 
R

Roel Schroeven

durumdara schreef:
Hi!

I wanna ask that have anyone some experience with email.msg and smtplib?

The email message and smtp.send already have "sender/from" and
"recip/addr to".
Possible the smtp components does not uses the email tags if I not
define them only in the message?

smtplib.SMTP.sendmail() does not look in the message to find the sender
or recipients; it only uses the parameters you pass.
Can I do same thing as in GMAIL that the mail does not have TO, only BCC
tags/recipients, and no one of the recipients who knows about the each
others?

Include the BCC-recipients in the call to sendmail(), but don't put them
in the email message itself. Include TO-recipients in both. In other
words, what you put in the TO-header is what all recipients will see;
what you pass to sendmail() is what recipients the mail will be send to.
Simple example (not tested):

from_addr = '(e-mail address removed)'
to_addr = ['(e-mail address removed)', '(e-mail address removed)']
bcc_addr = ['(e-mail address removed)', '(e-mail address removed)']

msg = """From: %s
To: %s
Subject: test

hello
""" % (from_addr, ', '.join(to_addr))

smtp = smtplib.SMTP(...)
smtp.sendmail(from_addr, to_addr + bcc_addr, msg)


--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
-- Isaac Asimov

Roel Schroeven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top