Skip to content

Commit ad7348d

Browse files
authored
Merge pull request #1 from hamsolo474/patch-1
Update gmail.py
2 parents ad476da + 2494ae8 commit ad7348d

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

gmail/gmail.py

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111

1212
#E-mail login credential
1313
gmail_id = ('') #sender g-mail id
14-
password = ('') #sender g-mail password
14+
gmail_password = ('') #sender g-mail password
1515

16-
#reciver mail id's
17-
reciver_mail_id = [
18-
'reciver_mail_id_1@gmail.com',
19-
'reciver_mail_id_2@gmail.com',
20-
'reciver_mail_id_3@gmail.com',
16+
#receiver mail id's
17+
destination_addresses = [
18+
'receiver_mail_id_1@gmail.com',
19+
'receiver_mail_id_2@gmail.com',
20+
'receiver_mail_id_3@gmail.com',
2121
'............................',
2222
'.............................',
23-
'reciver_mail_id_N [email protected]',
23+
'receiver_mail_id_N [email protected]',
2424
]
2525
#main subject
2626
subject = ('') #mail subject
27-
#mail contain
28-
mail_contain = ('') #mail contain
27+
#mail message
28+
message = ('') #mail message
2929

3030

3131
class loginCredential:
32-
def login(self,gmail_id, password):
32+
def login(self, gmail_id, gmail_password):
3333
self.gmail_id = gmail_id
34-
self._password = password
34+
self._password = gmail_password
3535

3636
server = smtplib.SMTP('smtp.gmail.com', 587)
3737
server.ehlo()
@@ -40,37 +40,34 @@ def login(self,gmail_id, password):
4040
server.login(self.gmail_id, self._password)
4141
return(server)
4242

43-
class reciverCredential(loginCredential):
44-
def reciver_mail(self, reciver_mail_id):
45-
self.reciver_mail_id =reciver_mail_id
43+
class receiverCredential(loginCredential):
44+
def receiver_mail(self, destination_addresses):
45+
self.destination_addresses = destination_addresses
4646

4747
mail_id = []
48-
for i in reciver_mail_id:
48+
for i in destination_addresses:
4949
mail_id.append(i)
5050
return(mail_id)
5151

52-
class gmail(reciverCredential):
53-
def send_mail(self, subject, mail_containt):
52+
class gmail(receiverCredential):
53+
def send_mail(self, subject, message):
5454
server = self.login(self.gmail_id, self._password)
55-
reciver_mail_id = self.reciver_mail(self.reciver_mail_id)
55+
destination_addresses = self.receiver_mail(self.destination_addresses)
5656

57-
containt = (f'subject: {subject}\n\n{mail_containt}')
57+
content = (f'subject: {subject}\n\n{message}')
5858

5959
server.sendmail(
6060
self.gmail_id,
61-
reciver_mail_id,
62-
containt
61+
destination_addresses,
62+
content
6363
)
64-
if len(reciver_mail_id) == 1:
65-
print('Mail has been sent to this : {}'.format(reciver_mail_id),'Address.')
66-
else:
67-
print('Mail has been sent to these : {}'.format(reciver_mail_id),'Address.')
64+
print('An Email has been sent to : {}'.format(' and '.join(destination_addresses)))
6865
server.quit()
6966

7067

7168

7269
if __name__ == '__main__':
7370
mail = gmail()
74-
mail.login(gmail_id, password)
75-
mail.reciver_mail(reciver_mail_id)
76-
mail.send_mail(subject, mail_contain)
71+
mail.login(gmail_id, gmail_password)
72+
mail.receiver_mail(destination_addresses)
73+
mail.send_mail(subject, message)

0 commit comments

Comments
 (0)