Merhabalar bu programımız gmail üzerinden toplu mail göndermizi sağlıyor arayüze entegre ettim gmailde uygulama şifresi alıp programdaki ilgili yere mailinizi ve gmail uygulama şifrenizi girdikten sonra programdaki diğer alanları doldurup toplu mail gönderimi yapabilirsiniz örnek kullanım alanı = şirketlere toplu iş başvurularında işe yarayabilir veya müşterilerinize toplu mail göndermelerde işe yarayabilir.
Python:
import tkinter as tk
from tkinter import ttk, filedialog, messagebox, scrolledtext
import yagmail
import re
import os
class CompactEmailManager:
def __init__(self, root):
self.root = root
self.root.title("Telegram = @Bytncpx")
self.root.geometry("1000x600")
self.colors = {
'bg': '#f8fafc', # Daha açık arka plan
'white': '#ffffff', # Panel arka planı
'primary': '#3b82f6', # Ana renk
'primary_hover': '#2563eb', # Hover durumu için
'secondary': '#64748b', # İkincil renk
'success': '#10b981', # Daha canlı başarı rengi
'success_hover': '#059669', # Hover durumu için
'error': '#ef4444', # Daha canlı hata rengi
'text': '#1e293b', # Ana metin
'text_light': '#64748b', # İkincil metin
'border': '#e2e8f0', # Kenarlık
'input_bg': '#f8fafc', # Input arka planı
'input_border': '#cbd5e1', # Input kenarlığı
'gradient_start': '#3b82f6', # Gradient başlangıç
'gradient_end': '#2563eb' # Gradient bitiş
}
self.fonts = {
'heading': ('Segoe UI', 16, 'bold'),
'subheading': ('Segoe UI', 12, 'bold'),
'normal': ('Segoe UI', 10),
'small': ('Segoe UI', 9)
}
self.attachments = []
self.setup_styles()
self.setup_ui()
def setup_styles(self):
style = ttk.Style()
style.theme_use('clam')
# Entry style
style.configure('Custom.TEntry',
fieldbackground=self.colors['input_bg'],
borderwidth=1,
relief='solid',
padding=5)
style.configure('Primary.TButton',
background=self.colors['primary'],
foreground=self.colors['white'],
padding=(15, 8),
font=self.fonts['normal'])
style.configure('Success.TButton',
background=self.colors['success'],
foreground=self.colors['white'],
padding=(20, 10),
font=self.fonts['normal'])
style.map('Primary.TButton',
background=[('active', self.colors['primary_hover'])])
style.map('Success.TButton',
background=[('active', self.colors['success_hover'])])
def setup_ui(self):
self.root.configure(bg=self.colors['bg'])
outer_frame = tk.Frame(self.root, bg=self.colors['bg'])
outer_frame.pack(fill='both', expand=True, padx=15, pady=15)
main_frame = tk.Frame(outer_frame, bg=self.colors['white'],
relief='solid', bd=1)
main_frame.pack(fill='both', expand=True)
header = tk.Canvas(main_frame, height=60, bg=self.colors['primary'],
highlightthickness=0)
header.pack(fill='x')
header.create_text(30, 30, text="Toplu E-posta Gönderme Servisi",
font=self.fonts['heading'], fill=self.colors['white'],
anchor='w')
content_frame = tk.Frame(main_frame, bg=self.colors['white'])
content_frame.pack(fill='both', expand=True, padx=20, pady=20)
left_panel = self.create_panel(content_frame)
left_panel.pack(side='left', fill='both', expand=True, padx=(0, 10))
# Sol panel içeriği
self.setup_left_panel(left_panel)
right_panel = self.create_panel(content_frame)
right_panel.pack(side='left', fill='both', expand=True, padx=(10, 0))
# Sağ panel içeriği
self.setup_right_panel(right_panel)
def setup_left_panel(self, parent):
# Gönderici bilgileri başlığı
header_frame = tk.Frame(parent, bg=self.colors['white'])
header_frame.pack(fill='x', pady=(0, 15))
tk.Label(header_frame, text="Gönderici Bilgileri",
font=self.fonts['subheading'],
bg=self.colors['white'],
fg=self.colors['text']).pack(anchor='w')
ttk.Separator(header_frame, orient='horizontal').pack(fill='x', pady=(5, 0))
# Gönderici form alanları
self.sender_email = self.create_entry(parent, "E-posta:", width=35)
self.sender_password = self.create_entry(parent, "Şifre:", width=35, show="•")
# Alıcılar başlığı
recipient_header = tk.Frame(parent, bg=self.colors['white'])
recipient_header.pack(fill='x', pady=(20, 10))
tk.Label(recipient_header, text="Alıcı Listesi",
font=self.fonts['subheading'],
bg=self.colors['white'],
fg=self.colors['text']).pack(anchor='w')
ttk.Separator(recipient_header, orient='horizontal').pack(fill='x', pady=(5, 0))
# Alıcı listesi
self.recipients = scrolledtext.ScrolledText(
parent, height=12, font=self.fonts['normal'],
bg=self.colors['input_bg'], relief='solid', bd=1)
self.recipients.pack(fill='both', expand=True, pady=(5, 0))
def setup_right_panel(self, parent):
# Mesaj başlığı
header_frame = tk.Frame(parent, bg=self.colors['white'])
header_frame.pack(fill='x', pady=(0, 15))
tk.Label(header_frame, text="Mesaj İçeriği",
font=self.fonts['subheading'],
bg=self.colors['white'],
fg=self.colors['text']).pack(anchor='w')
ttk.Separator(header_frame, orient='horizontal').pack(fill='x', pady=(5, 0))
# Konu ve mesaj alanları
self.subject = self.create_entry(parent, "Konu:", width=50)
message_label = tk.Label(parent, text="Mesaj:",
font=self.fonts['normal'],
bg=self.colors['white'],
fg=self.colors['text'])
message_label.pack(anchor='w', pady=(15, 5))
self.message = scrolledtext.ScrolledText(
parent, height=12, font=self.fonts['normal'],
bg=self.colors['input_bg'], relief='solid', bd=1)
self.message.pack(fill='both', expand=True)
# Ekler bölümü
attachment_frame = tk.Frame(parent, bg=self.colors['white'])
attachment_frame.pack(fill='x', pady=(15, 5))
tk.Label(attachment_frame, text="Ekler",
font=self.fonts['subheading'],
bg=self.colors['white'],
fg=self.colors['text']).pack(anchor='w')
ttk.Separator(attachment_frame, orient='horizontal').pack(fill='x', pady=(5, 10))
button_frame = tk.Frame(attachment_frame, bg=self.colors['white'])
button_frame.pack(fill='x')
attach_button = ttk.Button(button_frame, text="Dosya Ekle",
command=self.add_attachment,
style='Primary.TButton')
attach_button.pack(side='left')
self.attachment_list = tk.Listbox(
parent, height=3, font=self.fonts['small'],
bg=self.colors['input_bg'], relief='solid', bd=1)
self.attachment_list.pack(fill='x', pady=(5, 0))
send_frame = tk.Frame(parent, bg=self.colors['white'])
send_frame.pack(fill='x', pady=(15, 0))
self.status_var = tk.StringVar(value="Hazır")
status_label = tk.Label(send_frame,
textvariable=self.status_var,
font=self.fonts['small'],
bg=self.colors['white'],
fg=self.colors['text_light'])
status_label.pack(side='left')
send_button = ttk.Button(send_frame, text="GÖNDER",
command=self.send_emails,
style='Success.TButton')
send_button.pack(side='right')
def create_panel(self, parent):
return tk.Frame(parent, bg=self.colors['white'])
def create_entry(self, parent, label, width=None, show=None):
frame = tk.Frame(parent, bg=self.colors['white'])
frame.pack(fill='x', pady=5)
tk.Label(frame, text=label,
font=self.fonts['normal'],
bg=self.colors['white'],
fg=self.colors['text']).pack(side='left')
entry = ttk.Entry(frame, font=self.fonts['normal'],
width=width, show=show,
style='Custom.TEntry')
entry.pack(side='right')
return entry
def add_attachment(self):
files = filedialog.askopenfilenames(
title="Dosya Seç",
filetypes=[
("Tüm Dosyalar", "*.*"),
("PDF Dosyaları", "*.pdf"),
("Office Dosyaları", "*.docx;*.xlsx;*.pptx")
]
)
for file in files:
if file not in self.attachments:
self.attachments.append(file)
self.attachment_list.insert('end', os.path.basename(file))
def validate_email(self, email):
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
return re.match(pattern, email.strip()) is not None
def send_emails(self):
sender = self.sender_email.get().strip()
password = self.sender_password.get()
subject = self.subject.get().strip()
message = self.message.get('1.0', 'end').strip()
recipients = [r.strip() for r in self.recipients.get('1.0', 'end').strip().split('\n') if r.strip()]
if not all([sender, password, subject, message, recipients]):
messagebox.showerror("Hata", "Lütfen tüm alanları doldurunuz.")
return
valid_recipients = [r for r in recipients if self.validate_email(r)]
if len(valid_recipients) == 0:
messagebox.showerror("Hata", "Geçerli alıcı e-posta adresi bulunamadı.")
return
try:
self.status_var.set("Gönderiliyor...")
self.root.update()
yag = yagmail.SMTP(sender, password)
for recipient in valid_recipients:
yag.send(
to=recipient,
subject=subject,
contents=message,
attachments=self.attachments
)
messagebox.showinfo("Başarılı", f"{len(valid_recipients)} e-posta başarıyla gönderildi.")
self.status_var.set("Gönderim tamamlandı")
except Exception as e:
messagebox.showerror("Hata", f"Gönderim sırasında hata oluştu:\n{str(e)}")
self.status_var.set("Gönderim başarısız")
def main():
root = tk.Tk()
app = CompactEmailManager(root)
root.mainloop()
if __name__ == "__main__":
main()




