파이썬에서 results.txt 파일의 마지막 15 줄을 이메일로 보낼 전자 메일 기능을 설정하려고합니다. 어떻게 해야할지 모르겠다. 이메일 서버에 연결해야하는지 아니면 파이썬에 이메일을 보내는 다른 방법이 있는지 묻고 있었다. 아래의 코드는 내가 지금까지 가지고있는 것이고 어떤 도움을 주시면 감사하겠습니다. 감사합니다파이썬 텍스트 파일의 마지막 줄을 전자 메일로 보내기
import smtplib
# Import the email modules we'll need
from email.mime.text import MIMEText
# Open a plain text file for reading. For this example, assume that
# the text file contains only ASCII characters.
fp = open('/home/build/result.txt', 'r')
# Create a text/plain message
msg = MIMEText(fp.read())
fp.close()
me = '[email protected]'
you = '[email protected]'
msg['Subject'] = 'The contents of %s' % '/home/build/result.txt'
msg['From'] = me
msg['To'] = you
# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP()
s.sendmail(me, [you], msg.as_string())
s.quit()
안녕하세요 다시
I 서버가 연결되지 않습니다 연결을 시도하고있다. 이메일 주소를 입력해서는 안된다는 것을 알고 있습니다. 누구든지 호스트 정보를 작성하는 방법을 제안 할 수 있습니까? 감사합니다smtplib.SMTPServerDisconnected: please run connect() first