Help Debugging SMTP platform failure

I am having problems introducing the notify SMTP platform. When adding to an otherwise functional setup via the entries:

  - name: email_admin
    platform: smtp
    sender: !secret mail_sender
    port: 25
    recipient: !secret mail_recipient
    server: !secret mail_server
    username: !secret mail_account
    password: !secret mail_password
    encryption: starttls
    sender_name: "Home Assistant Instance"
    debug: True

This results in the following log entries:

2017-07-23 23:01:26 ERROR (MainThread) [homeassistant.components.notify] Error setting up platform smtp
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/notify/", line 101, in async_setup_platform platform.get_service, hass, p_config, discovery_info)
File "/usr/lib/python3.4/asyncio/", line 388, in __iter__ yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/", line 286, in _wakeup value = future.result()
File "/usr/lib/python3.4/asyncio/", line 277, in result raise self._exception
File "/usr/lib/python3.4/concurrent/futures/", line 54, in run result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/notify/", line 75, in get_service if mail_service.connection_is_valid():
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/notify/", line 120, in connection_is_valid server = self.connect()
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/notify/", line 106, in connect self._server, self._port, timeout=self._timeout)
File "/usr/lib/python3.4/", line 242, in __init__ (code, msg) = self.connect(host, port)
File "/usr/lib/python3.4/", line 321, in connect self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python3.4/", line 292, in _get_socket self.source_address)
File "/usr/lib/python3.4/", line 509, in create_connection raise err
File "/usr/lib/python3.4/", line 500, in create_connection sock.connect(sa)
socket.timeout: timed out

I am running HASSBIAN with the latest versions of HA.
My email server is local, and is seeing nothing from the RPi running the HAserver.
I have tried varying parameters:

  • port 25 or 587
  • server:F ip address, netbiod address, or full FQDN
  • debug: True and False
    I get the same eror whatever the settings!!

How can go about debugging this - I have plenty or computing expertise, but not in Python!
All suggestions welcome.


I have not used this component but anytime I need to set up a command line tool to send email, I like to use swaks. It will show you the realtime client / server communication. It will install on your Pi with
apt install swaks.
I would go the swaks creator page (Google it).
Hope this helps some.

I don’t know if this will help you, but this is a working gmail example:

  - name: sendemail
    platform: smtp
    port: 587
    timeout: 15
    sender: [email protected]
    starttls: true
    username: [email protected]
    password: mypassword
      - [email protected]
    sender_name: Home Assistant

I am slightly embarrassed to say this, but the problem sorted itself out - literally.
I unplugged everything in frustration, but in the morning when I rebooted, the SMTP component worked.
I am afraid I am not reassured that multiple "sudo reboot"s and service restarts failed, but a cold boot and an overnight worked.
Is there a way to “debug” these startup problems, that does not rely on incantations, or relying on “time the great healer”?

Paul McGinnie

I tend to use grep to find relevant information in the log files. The home-assistant.log and OZW_log.txt if you use Zwave in the configuration folder and /var/log/syslog I start with grep error and then move to other terms that turn up with error or some component I am working with. You can change the logging level in your configuration.yaml file. I wouldn’t leave it at debug, but it can be helpful if you are having issues.
Use the Configuration Validation tool in the HA UI to check configuration changes.

But “sleep on it” works too sometimes.