Bir metin dosyasına bir mesaj yazan ve bir e-posta olarak gönderen bir komut dosyası yazdım. Her şey iyi gidiyor, eposta hariç hepsi bir satırda görünüyor.Python'un smtplib'i kullanılarak e-postada satır sonları nasıl alınır?
\n
numaralı satır sonları ekledim ve metin dosyası için çalışıyor ancak e-posta için çalışmıyor. Olası sebep ne olabilir biliyor musunuz?
İşte benim kod: hepimiz için maalesef
import smtplib, sys
import traceback
def send_error(sender, recipient, headers, body):
SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
session = smtplib.SMTP('smtp.gmail.com', 587)
session.ehlo()
session.starttls()
session.ehlo
session.login(sender, 'my password')
send_it = session.sendmail(sender, recipient, headers + "\r\n\r\n" + body)
session.quit()
return send_it
SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
sender = '[email protected]'
recipient = '[email protected]'
subject = 'report'
body = "Dear Student, \n Please send your report\n Thank you for your attention"
open('student.txt', 'w').write(body)
headers = ["From: " + sender,
"Subject: " + subject,
"To: " + recipient,
"MIME-Version: 1.0",
"Content-Type: text/html"]
headers = "\r\n".join(headers)
send_error(sender, recipient, headers, body)
Çok teşekkür ederim. '\ r \ n' benim için çalışmıyor ama'
' yapar. –