无法使用python中的exchangelib与Microsoft Exchange邮件服务器连接

9nvpjoqh  于 4个月前  发布在  Python
关注(0)|答案(1)|浏览(67)

我试图使用python中的exchangeelib库连接到我的官方邮件服务器,但遇到错误
HTTP连接池(主机=“mail.domainnam.in,"矶钓=443):读取超时.(读取超时=120)

def send_mail(content):
    # Load environment variables from the .env file
    load_dotenv()

    # Access environment variables
    outlook_user = os.getenv('OUTLOOK_USER')
    outlook_password = os.getenv('OUTLOOK_PASS')
    outlook_server = os.getenv('OUTLOOK_SERVER')
    outlook_email = os.getenv('OUTLOOK_EMAIL')

    credentials = Credentials(
        username=outlook_user,
        password=outlook_password
        )

    config = Configuration(
        server=outlook_server,
        credentials=credentials
        )

    account = Account(
        primary_smtp_address=outlook_email,
        config=config,
        autodiscover=False,
        access_type=DELEGATE
        )

    msg = Message(
        account=account,
        subject="Test Mail",
        body=content,
        to_recipients=["email_address_1"],
        cc_recipients=["email_address_2"]
        )
    msg.send_and_save()

字符串
我试过这个线程,但没有一个解决方案工作“https://github.com/ecederstrand/exchangelib/issues/271“
请帮帮我

ldfqzlk8

ldfqzlk81#

调整exchangelib代码中的超时设置。

config = Configuration(
    server=outlook_server,
    credentials=credentials,
    timeout=30  # Adjust the timeout duration as needed
)

字符串

相关问题