• 海康摄像头配置QQ邮箱


    1.目的

    家内安装海康监控摄像头,苦于连接萤石云又要再单独购买硬盘录像机,因此尝试使用摄像头的邮箱报警功能。

    2.邮箱密钥测试

    我使用的是QQ邮箱,在QQ邮箱官网得到授权码后进行授权码测试。(QQ邮箱授权码获取请百度查询)

    import smtplib
    from email.mime.text import MIMEText
    from email.header import Header
    
    def send_email(sender, password, receiver, subject, message):
        # 设置邮件内容
        msg = MIMEText(message, 'plain', 'utf-8')
        msg['Subject'] = Header(subject, 'utf-8')
        msg['From'] = sender
        msg['To'] = receiver
    
        try:
            # 连接到 QQ 邮箱的 SMTP 服务器
            smtp_server = 'smtp.qq.com'
            smtp_port = 465  # 使用 SSL 加密连接
            smtp_username = sender
            smtp_password = password
    
            # 创建 SMTP 客户端对象并进行身份验证
            smtp_client = smtplib.SMTP_SSL(smtp_server, smtp_port)
            smtp_client.login(smtp_username, smtp_password)
    
            # 发送邮件
            smtp_client.sendmail(sender, receiver, msg.as_string())
            print("邮件发送成功!")
    
            # 关闭连接
            smtp_client.quit()
            return 0  # 发送成功,返回 0
        except smtplib.SMTPException as e:
            print("邮件发送失败:", str(e))
            return 1  # 发送失败,返回 1
    
    # 请替换为你的 QQ 邮箱账号和密码
    sender_email = 'your_email@qq.com'
    sender_password = 'your_password'
    
    # 请替换为接收者的邮箱地址
    receiver_email = 'receiver_email@example.com'
    
    # 邮件主题和内容
    email_subject = '测试邮件'
    email_message = '这是一封用于测试的邮件,请忽略。'
    
    # 发送邮件
    result = send_email(sender_email, sender_password, receiver_email, email_subject, email_message)
    if result == 0:
        print("邮件发送成功!")
    else:
        print("邮件发送失败!")
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51

    注意:这两处要根据自身情况修改。
    sender_email = ‘your_email@qq.com’
    sender_password = ‘your_password’
    经过测试,邮箱发送正常,说明QQ授权码没有问题。

    3.配置IP地址与DNS地址

    天若截图_20230902080030

    4.配置海康摄像头的EMAIL邮箱

    天若截图_20230902080537
    经过我的测试,只有这样才能测试成功,如不对欢迎指正。

    5.测试成功

    天若截图_20230902080621

    天若截图_20230902080826

  • 相关阅读:
    汽车企业能源管理工具_汽车生产能源管理系统_综合能源管控系统
    【百度地图】绘制扇形图层
    X11 Xlib截屏问题及深入分析四 —— XOpenDisplay函数源码分析(1)
    nvm vscode的问题
    MySQL进阶实战8,分区表详解
    SpringBoot 监控
    C# 窗体与子线程数据交互
    肠道微生物群与帕金森以及相关影响因素
    【报错】File ‘xxx.ui‘ is not valid
    MyBatis自定义映射resultMap,处理一对多,多对一
  • 原文地址:https://blog.csdn.net/xaioming18/article/details/132634088