1- SMTPserver = ''
2- sender = ''
3-
4- USERNAME = ""
5- PASSWORD = ""
6-
7- # typical values for text_subtype are plain, html, xml
8-
9- subject = "" # subject of the email
10-
111import sys
12- import os
2+ from os import name , system
133import re
144import csv
155import time
6+ from smtplib import SMTP_SSL as SMTP
7+ from email .mime .text import MIMEText
8+ from getpass import getpass
169
17- from smtplib import SMTP_SSL as SMTP # this invokes the secure SMTP protocol (port 465, uses SSL)
18- # from smtplib import SMTP # use this for standard SMTP protocol (port 25, no encryption)
1910
20- # old version
21- # from email.MIMEText import MIMEText
22- from email .mime .text import MIMEText
11+ def clear ():
12+ if name == 'nt' :
13+ _ = system ('cls' )
14+ else :
15+ _ = system ('clear' )
16+
17+ clear ()
18+ print ("Ensure you have saved your database file in the .csv format in this very directory!" )
19+ time .sleep (5 )
20+
21+ SMTPserver = input ("Enter server address: " )
22+ sender = input ("Email through which mails are to be sent: " )
23+ USERNAME = input ("Enter cpanel username: " )
24+ PASSWORD = getpass ("Enter cpanel password: " )
2325
24- conn = SMTP ( SMTPserver )
25- conn . set_debuglevel ( False )
26- conn . login ( USERNAME , PASSWORD )
27- with open ('tbm.csv ' ) as data :
26+ db = input ( "Enter the database file name with the extension: " )
27+ subject = input ( "Enter the subject of the email: " )
28+
29+ with open ('' + db + ' ' ) as data :
2830 row = csv .DictReader (data )
2931 for line in row :
3032 name = line ['First Name' ]
3133 add = line ['Email' ]
3234 text_subtype = 'html'
3335 # content
3436 content = """\
35-
3637 """
3738 msg = MIMEText (content , text_subtype )
3839 try :
5051 time .sleep (1 )
5152 exit ()
5253
53- conn .quit ()
54- # except:
55- # sys.exit( "mail failed; %s" % "CUSTOM_ERROR" ) # give an error message
54+ conn .quit ()
0 commit comments