You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修复HomeAssistant中notify.send_email的SMTP连接超时问题?

修复HomeAssistant中QQ邮箱SMTP通知连接超时问题

问题场景

  • 本地Python代码通过smtplib.SMTP_SSL连接QQ邮箱465端口,能正常发送邮件
  • HomeAssistant配置SMTP通知后,出现连接超时错误,日志提示smtplib.SMTPServerDisconnected: Connection unexpectedly closed: timed out

原因分析

QQ邮箱的465端口为SSL直连端口,要求直接建立加密连接;而配置中使用的encryption: starttls是先建立明文连接再升级为SSL,两者模式不匹配,导致连接超时。

解决方案

方案一:使用SSL加密(对应465端口)

修改configuration.yaml中的加密方式为ssl:

notify:
  - name: "send_email"
    platform: smtp
    server: "smtp.qq.com"
    port: 465
    timeout: 15
    sender: "x1@qq.com"
    encryption: ssl
    username: "x1@qq.com"
    password: "xxxx"
    recipient:
      - "x2@qq.com"
    sender_name: "send by homeassistant"

方案二:使用STARTTLS加密(对应587端口)

如果偏好STARTTLS模式,将端口改为587并保留encryption: starttls:

notify:
  - name: "send_email"
    platform: smtp
    server: "smtp.qq.com"
    port: 587
    timeout: 15
    sender: "x1@qq.com"
    encryption: starttls
    username: "x1@qq.com"
    password: "xxxx"
    recipient:
      - "x2@qq.com"
    sender_name: "send by homeassistant"

额外注意事项

  • 确认配置中的password是QQ邮箱的SMTP授权码,而非账号登录密码(需在QQ邮箱设置中开启POP3/SMTP服务并生成)
  • 检查HomeAssistant所在网络是否能访问对应端口(465/587),无防火墙或路由器拦截

内容的提问来源于stack exchange,提问作者showkey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 08:36:07