我想向用户发送警告电子邮件。在我的公司中,我们有一个交换服务器,但是我的应用程序没有专用帐户。因此,我想发送一个不回复发件人或发明发件人的消息。可能吗?如何配置凭据/帐户?
这是我的代码,但是需要使用某些用户的帐户。我想避免使用用户帐户。
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()