나는 yahoo
계정을 가지고 있습니다. 내 계정에서 이메일을 보낼 파이썬 코드가 있습니까?파이썬에서 야후 계정을 사용하여 전자 메일 보내기
6
A
답변
11
예; 코드는 다음과 같습니다.
import smtplib
fromMy = '[email protected]' # fun-fact: from is a keyword in python, you can't use it as variable, did abyone check if this code even works?
to = '[email protected]'
subj='TheSubject'
date='2/1/2010'
message_text='Hello Or any thing you want to send'
msg = "From: %s\nTo: %s\nSubject: %s\nDate: %s\n\n%s" % (fromMy, to, subj, date, message_text)
username = str('[email protected]')
password = str('yourPassWord')
try :
server = smtplib.SMTP("smtp.mail.yahoo.com",587)
server.login(username,password)
server.sendmail(fromMy, to,msg)
server.quit()
print 'ok the email has sent '
except :
print 'can\'t send the Email'
2
비 ASCII 문자를 지원하려면 다음을 입력하십시오. 당신은 email
package을 사용할 수 있습니다 : 나는 야후의 SMTP 서버를 사용에 대한 내 머리 (간략하게) 랙
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from email.header import Header
from email.mime.text import MIMEText
from getpass import getpass
from smtplib import SMTP_SSL
# provide credentials
login = '[email protected]'
password = getpass('Password for "%s": ' % login)
# create message
msg = MIMEText('message body…', 'plain', 'utf-8')
msg['Subject'] = Header('subject…', 'utf-8')
msg['From'] = login
msg['To'] = ', '.join([login, ])
# send it
s = SMTP_SSL('smtp.mail.yahoo.com', timeout=10) #NOTE: no server cert. check
s.set_debuglevel(0)
try:
s.login(login, password)
s.sendmail(msg['From'], msg['To'], msg.as_string())
finally:
s.quit()
5
. 465 그냥 작동하지 않을 것입니다. 나는 포트 587을 통해 TLS 경로를 가기로 결정했고 나는 인증하고 이메일을 보낼 수 있었다.
import smtplib
from email.mime.text import MIMEText
SMTP_SERVER = "smtp.mail.yahoo.com"
SMTP_PORT = 587
SMTP_USERNAME = "username"
SMTP_PASSWORD = "password"
EMAIL_FROM = "[email protected]"
EMAIL_TO = "[email protected]"
EMAIL_SUBJECT = "REMINDER:"
co_msg = """
Hello, [username]! Just wanted to send a friendly appointment
reminder for your appointment:
[Company]
Where: [companyAddress]
Time: [appointmentTime]
Company URL: [companyUrl]
Change appointment?? Add Service??
change notification preference (text msg/email)
"""
def send_email():
msg = MIMEText(co_msg)
msg['Subject'] = EMAIL_SUBJECT + "Company - Service at appointmentTime"
msg['From'] = EMAIL_FROM
msg['To'] = EMAIL_TO
debuglevel = True
mail = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
mail.set_debuglevel(debuglevel)
mail.starttls()
mail.login(SMTP_USERNAME, SMTP_PASSWORD)
mail.sendmail(EMAIL_FROM, EMAIL_TO, msg.as_string())
mail.quit()
if __name__=='__main__':
send_email()
관련 문제
- 1. 자바 전자 메일 및 야후
- 2. codeigniter를 사용하여 전자 메일 보내기
- 3. MFMailComposeViewController를 사용하여 전자 메일 보내기
- 4. 서블릿을 사용하여 전자 메일 보내기
- 5. OAuth를 사용하여 전자 메일 보내기
- 6. Python을 사용하여 전자 메일 보내기
- 7. Javamail을 사용하여 전자 메일 보내기
- 8. RMAIL을 사용하여 전자 메일 보내기
- 9. Wordpress를 사용하여 전자 메일 보내기
- 10. asp.net을 사용하여 전자 메일 보내기
- 11. Outlook을 사용하여 전자 메일 보내기
- 12. JavaMail을 사용하여 업무용 전자 메일 서버에 전자 메일 보내기
- 13. Heroku에서 Rails4를 사용하여 전자 메일 보내기
- 14. Outlook을 사용하여 메일 그룹에 전자 메일 보내기
- 15. 전자 메일 보내기 automaticlly
- 16. Pylons에서 전자 메일 보내기
- 17. TIdSMTP 및 TIdMessage를 사용하여 전자 메일 보내기
- 18. 엄청난 전자 메일 보내기
- 19. 전자 메일 보내기
- 20. 전자 메일 클라이언트 호환 전자 메일 보내기
- 21. 전자 메일 양식 만들기 전자 메일 보내기
- 22. 여러 전자 메일 보내기
- 23. 비동기 전자 메일 보내기
- 24. PHP로 전자 메일 보내기
- 25. 양식에서 전자 메일 보내기
- 26. goroutine에서 전자 메일 보내기
- 27. 비동기 전자 메일 보내기
- 28. PayPal 구매자에게 전자 메일 보내기
- 29. VBA를 사용하여 Outlook의 그룹 전자 메일 주소에서 전자 메일 보내기
- 30. Python을 사용하여 TLS를 통해 전자 메일 보내기
server.starttls()는 server.login과 함께 추가해야합니다. 그렇지 않으면 예외가 발생합니다. – user6972
'SMTP AUTH 확장 기능이 서버에서 지원되지 않습니다 .' – Volatil3