0
votes

My all code :`

import smtplib
from email.mime.text import MIMEText


smtp_adresi="smtp.gmail.com"
smtp_port=587
user="****@gmail.com"
pass="*****"


gonderilecek_adresler=["****@bilalkocak.net","******@gmail.com"]
konu="Subject"
content="HTML content"



mail=MIMEText(content,"html","UTF-8")

mail["From"]=kullanıcı_adı

mail["Subject"]=konu

mail["To"]=",".join(gonderilecek_adresler)

mail=mail.as_string()


s=smtplib.SMTP(smtp_adresi,smtp_port)

s.starttls()

s.login(user,pass)

s.sendmail(user,gonderilecek_adresler,mail)

Result:

C:\Users\ASUS\AppData\Local\Programs\Python\Python36-32\python.exe "C:/Users/ASUS/PycharmProjects/Again/SMTP ile Mail/main.py" 'utf-8' codec can't decode byte 0xe7 in position 7: invalid continuation byte

Process finished with exit code 0

1
"utf - 8" why the spaces are needed? Try without them "utf-8" - omri_saadon
I tried, but the result is the same - Bilal Koçak
# -*- coding: utf-8 -*- insert this in your first line. - omri_saadon
unfortunately it has not changed - Bilal Koçak
\xe7 is the ç in your name but not encoded in UTF-8 (maybe cp1254, Turkish name?). Save your source file in UTF-8 and try again. It helps to have a reproducible example. Your ****** in the source probably removed the problem. - Mark Tolonen

1 Answers

0
votes

\xe7 is the ç in your name but not encoded in UTF-8 (maybe cp1254, Turkish name?). Save your source file in UTF-8 and try again. It helps to have a reproducible example. Your ****** in the source probably removed the problem.

Note #coding:utf8 at the top of the file declares the encoding of the file, but it is the default in Python 3 so it is not required. Python 2 would need it.