Python Forum
email notification - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: email notification (/thread-6208.html)



email notification - sritsv - Nov-10-2017

Hello Team,
can anyone help me understand why is the email not triggered.
class mailnotify():
def check_db_conn(self):
try:
conn_string = "dbname='dbane' host='hostname' port='protno' user='user' password='pwd'"
return conn_string
except:
print "Unable to connect to the database"
text = "Unable to Connect to Database"
subject = "Test Non-Prod Running EC2 Instances"
self.email_notify(subject,text)
sys.exit(1)

def email_notify(self,subject,text):
fromaddr = "fromaddr"
toaddr = "toaddr"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = subject
body = text
msg.attach(MIMEText(body))
server = smtplib.SMTP('exchange.xyz.net', 25)
text = msg.as_string()
server.sendmail(fromaddr,toaddr,text)
server.quit()

if __name__=="__main__":
p = mailnotify()
p.check_db_conn()

Please note program/script runs fine, but email isnt sent out.


RE: email notification - heiner55 - Nov-11-2017

Why should your script run well, if you are using sample data like:
  fromaddr = "fromaddr"
  toaddr = "toaddr"

If you need more help, you should post your code between code tags, see BBCODE


RE: email notification - Spendor - Nov-29-2018

Hello i would like to ask you to help me or to guide me in this process if it's possible ;
i was asked to make an application where we have an alerte system for equipements maintenance ; when the maintenance day approach we will recieve an email as a reminder . I need a Graphical design and i was told that Pyqt will do the job and they told me that using python will the best choice .

If you can help or give me any recomnadation it will be really helpyful .

Thank you .