Senden Sie japanische Post mit Python3.
#!/bin/env python3
import smtplib
from email.mime.text import MIMEText
import datetime
jp='iso-2022-jp'
# file.Der Inhalt, den Sie senden möchten, ist in txt enthalten
fp = open('file.txt')
raw_msg = fp.read()
msg = MIMEText(raw_msg.encode(jp), 'plain', jp,)
fp.close()
fromaddr = "[email protected]"
toaddr = "[email protected]"
#Wird bei der Angabe des Betreffs verwendet
d = datetime.datetime.today()
date = d.strftime("%Y-%m-%d")
msg['Subject'] = date+"Nutzungsinformationen"
msg['From'] = fromaddr
msg['To'] = toaddr
try:
server = smtplib.SMTP('localhost')
server.send_message(msg)
print("Successfully sent email")
except Exception:
print("Error: unable to send email")
##Referenz
## http://w.builwing.info/2013/09/21/python3-3%E3%81%A7%E3%83%A1%E3%83%BC%E3%83%AB%E9%80%81%E4%BF%A1/