1

我想向用户发送警告电子邮件。在我的公司,我们有一个交换服务器,但我的应用程序没有专用帐户。所以,我想用 noreply 发件人或发明的发件人发送消息。可能吗?如何配置凭据/帐户?

这是我拥有的代码,但它需要使用一些用户的帐户。我想避免使用用户的帐户。

from exchangelib import DELEGATE, Account, Credentials, Configuration, Message, Mailbox

creds = Credentials(
username="DOMAIN\\my.login", 
password="")

config = Configuration(server='server.company.com', credentials=creds)

account = Account(
primary_smtp_address="myemail@company.com",
autodiscover=False, 
config = config,
access_type=DELEGATE)

m = Message(
    account=account,
    subject='Daily',
    body='BOdy test',
    to_recipients=[
        Mailbox(email_address='recip@test.com'),
    ],
    cc_recipients=['cc_recip@test.com'],  
    bcc_recipients=[
        Mailbox(email_address='bcc_recip@test.com'),
    ],  
)

m.send()
4

0 回答 0