-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailSenderGUI.py
More file actions
87 lines (60 loc) · 2.2 KB
/
EmailSenderGUI.py
File metadata and controls
87 lines (60 loc) · 2.2 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#! usr/bin/python3
"""
This GUI Application helps you send single email to receipients
"""
import sys
import smtplib
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from email.mime.text import MIMEText as text
class Window(QWidget):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
form=QFormLayout()
info=QLabel("This Application Help\'s you send emails")
senderLabel=QLabel("Sender\'s Email Address : ")
self.sender=QLineEdit()
receiverLabel=QLabel("Receipient\'s Email Adress :")
self.receiver=QLineEdit()
self.msg=QTextEdit("Compose your message here")
subjectLabel=QLabel("Subject: ")
self.subjectText=QLineEdit()
self.sendBtn=QPushButton("Submit")
form.addRow(info)
form.addRow(senderLabel)
form.addRow(self.sender)
form.addRow(receiverLabel)
form.addRow(self.receiver)
form.addRow(subjectLabel,self.subjectText)
form.addRow(self.msg)
form.addRow(self.sendBtn)
self.sendBtn.clicked.connect(self.EmailSender)
self.setGeometry(100,100,400,450)
self.setWindowTitle(" Email Sender ")
self.setLayout(form)
def EmailSender(self):
try:
message=self.msg.toPlainText()
sndr=self.sender.text()
receipient=self.receiver.text()
subject=self.subjectText.text()
m=text(message)
m['Subject']=subject
m['From']=sndr
m['To']=receipient
server= smtplib.SMTP('smtp.gmail.com',587)
server.starttls()
server.login("youremail@gmail.com","xxxxxx")
server.sendmail(sndr,receipient, m.as_string())
server.quit()
self.msg.clear()
self.sender.clear()
self.receiver.clear()
QMessageBox.information (self,"Email Alert","Email Successfully Sent")
except:
QMessageBox.information (self,"Email Alert","Check your inputted information")
if __name__=="__main__":
app=QApplication(sys.argv)
win=Window()
win.show()
sys.exit(app.exec_())