Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
email notification
#1
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.
Reply
#2
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
Reply
#3
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 .
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Sound Sensor With EMail Notification parascand 1 440 Dec-10-2023, 03:10 AM
Last Post: deanhystad
  Error notification after encoding robertje1024 1 1,163 May-29-2022, 04:18 PM
Last Post: Axel_Erfurt
  How to make scraper send email notification just once themech25 0 1,362 Nov-08-2021, 01:51 PM
Last Post: themech25
  Can't read virtual pin or use notification on blynk flypon 1 3,090 Oct-28-2021, 02:32 PM
Last Post: ChanceTran
  running python script showing an icon in the tray notification area chubbychub 1 4,476 Nov-01-2020, 03:52 PM
Last Post: jefsummers
  psutil for monitor a software finish process and notification Pyguys 0 2,817 Mar-27-2020, 11:15 PM
Last Post: Pyguys
  Email Notification mbelfortas 1 2,383 Oct-03-2018, 07:24 AM
Last Post: buran
  An email with inline jpg cannot be read by all email clients fpiraneo 4 3,932 Feb-25-2018, 07:17 PM
Last Post: fpiraneo
  Email - Send email using Windows Live Mail cyberzen 2 5,873 Apr-13-2017, 03:14 AM
Last Post: cyberzen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020