-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmtp_test.py
More file actions
44 lines (34 loc) · 1.21 KB
/
smtp_test.py
File metadata and controls
44 lines (34 loc) · 1.21 KB
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
import smtplib
import ssl
def test_gmail_smtp(email, app_password):
"""Test Gmail SMTP specifically"""
print(f"Testing Gmail SMTP for: {email}")
try:
# Gmail SMTP settings
smtp_server = "smtp.gmail.com"
port = 587
# Create SMTP session
server = smtplib.SMTP(smtp_server, port)
server.starttls() # Enable security
server.login(email, app_password)
# Send test email
subject = "Gmail SMTP Test - Dev Digest"
body = "If you receive this, your Gmail SMTP is working!"
message = f"Subject: {subject}\n\n{body}"
server.sendmail(email, email, message)
server.quit()
print("✅ Gmail SMTP test successful!")
print("📧 Check your Gmail inbox")
return True
except smtplib.SMTPAuthenticationError:
print("❌ Authentication failed!")
print("💡 Check your app password")
return False
except Exception as e:
print(f"❌ Error: {e}")
return False
# Replace with your credentials
email = "your_email"
app_password = "your_password"
if __name__ == "__main__":
test_gmail_smtp(email, app_password)