-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSMTPileMailGönderme.py
55 lines (29 loc) · 1.25 KB
/
SMTPileMailGönderme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""TXT UZANTILI DOSYAYA MAİLİ GÖNDERMEK İSTEDİĞİMİZ MAİL ADRESLERİNİ YAZIYORUZ VE BÖYLECE TOPLU MAİL GÖNDERME İŞLEMİ GERÇEKLEŞTİRMİŞ OLUYORUZ.
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import sys
with open("mail.txt","r",encoding="utf-8") as file:
for satır in file:
satır = satır[:-1]
satır_elemanları = satır.split(",")
mesaj = MIMEMultipart()
mesaj["From"] = "mailin_gonderildigi_mail_adresi"
mesaj["To"] = satır_elemanları[1]
mesaj["Subject"] = "Smtp Mail Gönderme"
yazi ="""
Smtp ile mail gönderiyorum..
"""
mesaj_govdesi = MIMEText("Merhaba\n"+satır_elemanları[0]+yazi, "plain")
mesaj.attach(mesaj_govdesi)
try:
mail = smtplib.SMTP("smtp.gmail.com", 587)
mail.ehlo()
mail.starttls()
mail.login("mail_adresi", "sifre")
mail.sendmail(mesaj["From"], mesaj["To"], mesaj.as_string())
print("Mail Başarıyla Gönderildi....")
mail.close()
except:
sys.stderr.write("Bir sorun oluştu!")
sys.stderr.flush()