Open kt8000 opened 4 years ago
Hi kt8000,
is there any chance you could post your emailer.py? I don't have the skills to add your code to my emailer.py.
or could you tell me what code to insert, and where?
I'm getting the same error as you.
Thanks in advance
Here is the whole file zipped if it helps.
Thanks kt8000, much appreciated.
On a rasberry PI 4b with the latest python 2.7, smtplib.SMTP() seems to expect an integer for the second argument. I get an error whenever alarmd tries to send an email.
In /etc/alarmd_config.ini, I have:
[EmailNotification] notification_email = user@gmail.com notification_subject = Alarm Notification username = user@gmail.com password = 1234567812345678 server_address = smtp.gmail.com port = 587 tls = true
Running the notification-test gives the following error:
root@raspberrypi:/home/pi# alarmd --notification-test Jul 24 20 12:49:20 PM alarmd[7723]: [main.INFO] Notification test starting... Jul 24 20 12:49:20 PM alarmd[7723]: [notify.INFO] Sending notifications... Jul 24 20 12:49:20 PM alarmd[7723]: [emailer.INFO] Sending email... Traceback (most recent call last): File "/usr/local/bin/alarmd", line 11, in
load_entry_point('alarm-central-station-receiver==1.0.0', 'console_scripts', 'alarmd')()
File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/main.py", line 251, in main
notification_test_exit(args.config_path)
File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/main.py", line 111, in notification_test_exit
notify_test()
File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/notifications/notify.py", line 39, in notify_test
notify_async(events)
File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/notifications/notify.py", line 44, in notify_async
emailer.notify(events)
File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/notifications/notifiers/emailer.py", line 68, in notify
s = smtplib.SMTP(server, server_port)
File "/usr/lib/python2.7/smtplib.py", line 256, in init
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py", line 317, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.7/smtplib.py", line 292, in _get_socket
return socket.create_connection((host, port), timeout)
File "/usr/lib/python2.7/socket.py", line 557, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.error: getaddrinfo() argument 2 must be integer or string
I updated emailer.py and changed the second argument to an integer to resolve this:
'diff emailer.py emailer.py.new ' '57a58,59' '> server_port_num = int(server_port)' '> ' '68c70,71' '< s = smtplib.SMTP(server, server_port)' '---' '> ' '> s = smtplib.SMTP(server, server_port_num)'