Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You don't need to create a separate email message for each recipient; just send a single message with multiple recipients:</p> <pre><code>def send_mail(send_from,send_to, subject, text, files=[], server = "localhost"): msg = MIMEMultipart() msg['From'] = send_from msg['To'] = COMMASPACE.join(send_to) # ... server = smtplib.SMTP(server) server.sendmail(send_from, send_to, msg.as_string()) server.close() </code></pre> <p>This is almost identical to the example "Here’s an example of how to send a MIME message containing a bunch of family pictures that may be residing in a directory" in the <a href="http://docs.python.org/2/library/email-examples.html" rel="nofollow">docs</a>.</p> <p>(If you don't want each person to see the other's addresses, you can make them all <code>BCC</code>s instead of <code>To</code>s.)</p> <p>If you're more interested in what's wrong with your original code, than with how to do it properly, there are two immediately visible problems:</p> <ol> <li>You're <code>join</code>ing each address, as Vader explains.</li> <li>You're passing a single address as a string as the second argument to <a href="http://docs.python.org/2/library/smtplib.html#smtplib.SMTP.sendmail" rel="nofollow"><code>SMTP.sendmail</code></a>, but the second argument is a sequence of addresses. To fix that, use <code>[s]</code> instead of <code>s</code>, as most of the examples do.</li> </ol> <p>Both of these are caused by the same confusion, treating each address as a list of addresses. You may have additional errors caused by the same problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload