-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailsend.py
39 lines (29 loc) · 1.21 KB
/
mailsend.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
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
import time
sender_email = "[email protected]" # gönderen e-posta
sender_password = "password" # gönderen 2FA parolası
subject = "HTML E-posta" # e-posta konusu
with open("email.html", "r") as file:
html_content = file.read()
with open("mailler.txt", "r") as file: # mail listesi (mailler.txt)
mailler = file.read().splitlines()
for mail in mailler:
try:
msg = MIMEMultipart()
msg["From"] = sender_email
msg["To"] = mail
msg["Subject"] = subject
html_part = MIMEText(html_content, "html")
msg.attach(html_part)
with smtplib.SMTP("smtp.gmail.com", 587) as server:
server.starttls()
server.login(sender_email, sender_password)
server.sendmail(sender_email, mail, msg.as_string())
print(f"E-posta gönderildi: {mail}")
# time.sleep(60) Attıktan sonra beklemesini istiyorsan "#" ı sil ve "60" yerine beklenecek saniyeyi gir.
except Exception as e:
print(f"Hata: {e}")
print("Tüm e-postaların gönderimi tamamlandı.")