当前位置:论坛首页 > Linux面板 > 求助

【已完成】电子邮箱用我们公司自己的exchange 2019服务器,不

发表在 Linux面板2023-8-1 13:16 [复制链接] 5 1866

本帖最后由 堡塔运维香菜卷 于 2023-8-9 23:26 编辑

为了能快速了解并处理您的问题,请提供以下基础信息:
面板、插件版本:8.0.0
系统版本:Ubuntu 20.04.6 LTS x86_64(Py3.7.9)
问题描述:电子邮箱用我们公司自己的邮箱,发送不了电子邮件,我们用python写的邮件发送是可以发送过去的。端口465和587都行。但是在宝塔面板上就不可以
相关截图(日志、错误):发送失败,请检查发送者配置或者接收者信息是否正确.

使用道具 举报 只看该作者 回复
发表于 2023-8-1 13:37:55 | 显示全部楼层
  1. import smtplib
  2. from email.mime.text import MIMEText
  3. from email.mime.multipart import MIMEMultipart

  4. def send_email(sender_email, sender_password, receiver_email, subject, body):
  5.     try:
  6.         # SMTP server configuration
  7.         smtp_server = 'xxx.net'
  8.         smtp_port = 465

  9.         # Create a secure connection to the server
  10.         server = smtplib.SMTP(smtp_server, smtp_port)
  11.         server.starttls()

  12.         # Log in to the server
  13.         server.login(sender_email, sender_password)

  14.         # Create a message
  15.         message = MIMEMultipart()
  16.         message['From'] = 'xxx@ xxxx.net'
  17.         message['To'] = 'xxx@ xxxx.net'
  18.         message['Subject'] = subject

  19.         # Add body to the message
  20.         message.attach(MIMEText(body, 'plain'))

  21.         # Send the email
  22.         server.sendmail(sender_email, receiver_email, message.as_string())

  23.         # Close the connection
  24.         server.quit()
  25.         print("Email sent successfully!")
  26.     except Exception as e:
  27.         print(f"An error occurred: {e}")

  28. # Usage example
  29. if __name__ == "__main__":
  30.     sender_email = 'xxx@ xxxx.net'
  31.     sender_password = ''  # Replace with the actual password
  32.     receiver_email = xxx@ xxxx.net'
  33.     subject = 'Test Email'
  34.     body = 'This is a test email sent using Python SMTP.'

  35.     send_email(sender_email, sender_password, receiver_email, subject, body)
复制代码
这是我的python代码,发送邮件没有问题,公网和内网均可以
使用道具 举报 回复 支持 反对
发表于 2023-8-1 14:31:25 | 显示全部楼层
您好,您是用面板内的邮局插件还是您自己写的代码?如果是您自己写的代码,面板内是没有做过限制的。这个需要您检查下您自己代码问题。

如果是邮局插件,您可以结合邮局插件日志进行一个排查。
使用道具 举报 回复 支持 反对
发表于 2023-8-2 19:48:35 | 显示全部楼层
我使用系统内置的通知配置,这个日志在哪里看?
使用道具 举报 回复 支持 反对
发表于 2023-8-4 09:31:31 | 显示全部楼层
itaustin 发表于 2023-8-2 19:48
我使用系统内置的通知配置,这个日志在哪里看?

系统内的所有日志存放在:/var/log目录下,您找下。
使用道具 举报 回复 支持 反对
发表于 2023-8-6 00:15:35 | 显示全部楼层
麻烦反馈下,这个系统通知的邮件,支持一下esmtp,exchange。
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

点击联系技术免费分析

工作时间:09:00至18:30

快速回复 返回顶部 返回列表