2017-11-30 1 views
0

벨로우즈 코드 사용 하나의 계정으로 전자 메일을 보낼 수 있지만 어떻게 다중 계정으로 보낼 수 있습니까?smtplib을 사용하여 여러 주소로 전자 메일을 보내려면 어떻게합니까?

import smtplib 
from email.mime.text import MIMEText 

_user = "[email protected]" # 
_pwd = "orjxywulscbxsdwbaii" # 
_to = [email protected]" # 

msg = MIMEText("content") # 
msg["Subject"] = "邮件主题测试" # 
msg["From"] = _user 
msg["To"] = _to 

try: 
    s = smtplib.SMTP_SSL("smtp.qq.com", 465) 
    s.login(_user, _pwd) 
    s.sendmail(_user, _to, msg.as_string()) 
    s.quit() 
    print ("Success!") 
except smtplib.SMTPException as e: 
    print ("Falied,%s" % e) 
+1

의 사용 가능한 복제 [파이썬 : TO, CC와 BCC 메일을 보내는 방법 (https://stackoverflow.com/questions/1546367/python-how -to-send-mail-to-cc-and-bcc) –

+0

이메일 주소 목록을 '_to'로 지정할 수 있습니다.이 's.sendmail (_user, [_to], msg.as_string())' – GeekSambhu

+0

@ GeekSambhu 고마워, 알았다. –

답변

-1

이 시도 :

import smtplib 
from email.mime.text import MIMEText 

s = smtplib.SMTP('smtp.qq.com') 
s.set_debuglevel(1) 
msg = MIMEText("""body""") 
sender = '[email protected]' 
recipients = ['[email protected]', '[email protected]'] 
msg['Subject'] = "subject line" 
msg['From'] = sender 
msg['To'] = ", ".join(recipients) 
s.sendmail(sender, recipients, msg.as_string()) 
+0

솔루션에 대한 의견 수렴 –

관련 문제