views:

164

answers:

2

1 -

In my email-sending script, I store spaced-out emails in a string, then I use ", ".join(to.split()). However, it looks like the script only sends to the 1st email - is it something to do with RFC822 format? If so, how can I fix this?

2 -

I feel a bit edgy having my password visable in my script. Is there a way to retrieve this info from cookies or saved passwords from firefox?

Thanks in advance!

+2  A: 

Use ', '.join() for the list in the To: or Cc: header, but the headers are only for show. What determines where the mail actually goes is the RCPT envelope. Assuming you're using smtplib, that's the second argument:

connection.sendmail(senderaddress, to.split(), mailtext)

2: it's possible, but far from straightforward. Browsers don't want external programs looking at their security-sensitive stored data.

bobince
Thanks a bunch! I was wondering why it was properly displaying in the header, yet not sending.
echoblaze
+1  A: 

For the second part of your question, you could take a look at the netrc module (http://docs.python.org/library/netrc.html).

This isn't much better than having the password in the script, but it does allow the script to be readable for anyone using the computer, while you have the password in a file in your home directory that is only readable by you.

Epcylon