선 밖에 선 자유인

python3 메일 보내기 예제 본문

IT/Programming

python3 메일 보내기 예제

Hotman 2017. 3. 29. 11:19
출처: http://stackoverflow.com/questions/24077314/how-to-send-an-email-with-style-in-python3
#!/usr/bin/python3

 import smtplib

msg_header = 'From: Sender Name \n' \
    'To: Receiver Name \n' \
    'Cc: Receiver2 Name \n' \
    'MIME-Version: 1.0\n' \
    'Content-type: text/html\n' \
    'Subject: Any subject\n'

title = 'My title'
msg_content = '


\n'.format(title=title) msg_full = (''.join([msg_header, msg_content])).encode() server = smtplib.SMTP("smtp 서버=":25') server.starttls() #server.login('sender@server', '') server.sendmail('receiver@server', ['receiver2@server', 'receiver3@server'], msg_full) server.quit()


Comments