15-07-2019, 22:32
Updated files on GitHub
Changelog:
- Changes in handling of the unit type to have full compatibility with the WeeWx plugin
Changelog:
- Changes in handling of the unit type to have full compatibility with the WeeWx plugin
Quote:2020-02-08 10:56:58 Logging script started.
08.02.2020 10:58:59 Mail could not be sent.
try:
# call sendmail() and generate a new mail with specified subject and content
if EnableDebug == 1:
print "Sending Email."
sendmail(str(receiver),'Wetterstation error',str(datetime.now().strftime("%d.%m.%Y %H:%M:%S")) + ' No data is logged since 10 minutes')
if EnableErrorLog == 1:
with open(ErrorLog,'a') as err:
err.write (str(datetime.now().strftime("%d.%m.%Y %H:%M:%S")) +" Mail sent to " + str(receiver) + "\n")
mailSent = 1
except:
if EnableErrorLog == 1:
with open(ErrorLog,'a') as err:
err.write (str(datetime.now().strftime("%d.%m.%Y %H:%M:%S")) +" Mail could not be sent. \n")
mailSent = 1 # try:
# call sendmail() and generate a new mail with specified subject and content
if EnableDebug == 1:
print "Sending Email."
sendmail(str(receiver),'Wetterstation error',str(datetime.now().strftime("%d.%m.%Y %H:%M:%S")) + ' No data is logged since 10 minutes')
if EnableErrorLog == 1:
with open(ErrorLog,'a') as err:
err.write (str(datetime.now().strftime("%d.%m.%Y %H:%M:%S")) +" Mail sent to " + str(receiver) + "\n")
mailSent = 1
#except:
#if EnableErrorLog == 1:
#with open(ErrorLog,'a') as err:
#err.write (str(datetime.now().strftime("%d.%m.%Y %H:%M:%S")) +" Mail could not be sent. \n")
#mailSent = 1Quote: .......In error log :
Rain_TX3: 0.0 mm
Rain_Rate_TX3: 0.0 mm/h
Actual timestamp:2020-02-08 22:54:48; Timestamp at sending:2020-02-08 22:54:53
Sending Email.
An error has happened during receiving. Waiting 5 minutes and start over again
2020-02-08 23:00:49 Open serial interface COM14
2020-02-08 23:00:49 Successfully opened.
Sending Email.
An error has happened during receiving. Waiting 5 minutes and start over again
Quote:2020-02-08 22:55:48 Error receiving data from serial port. Maybe connection was lost. Error code:15
2020-02-08 23:00:49 Error receiving data from serial port. Maybe connection was lost. Error code:15
Quote: sendmail(str(receiver),'Wetterstation error',str(datetime.now().strftime("%d.%m.%Y %H:%M:%S")) + ' TEST')Thanks
File "Z:\Partage\Projets\Arduino\WD\Ori\WeatherDuino_Addon\sendmail.py", line 7, in sendmail
msg = MIMEText(content)
NameError: global name 'MIMEText' is not defined
#
# function to send a mail
#
def sendmail(recipient,subject,content):
from email.mime.text import MIMEText
import smtplib
# generate a RFC 2822 message
sender = 'Sender@mail.com'
smtpserver = 'smtp.free.fr'
msg = MIMEText(content)
msg['From'] = sender
msg['To'] = recipient
msg['Subject'] = subject
# open SMTP connection
server = smtplib.SMTP(smtpserver)
# start TLS encryption
#if usetls:
#server.starttls()
# login with specified account
#if smtpusername and smtppassword:
#server.login(smtpusername,smtppassword)
# send generated message
server.sendmail(sender,recipient,msg.as_string())
# close SMTP connection
server.quit()
