exchangelib-自动发现协议中的所有步骤均失败 [英] exchangelib - All steps in the autodiscover protocol failed

查看:769
本文介绍了exchangelib-自动发现协议中的所有步骤均失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在python中使用exchangelib时遇到问题.我尝试下面的示例代码:

I have a problem with using exchangelib in python. I try this example code:

from exchangelib import DELEGATE, Account, Credentials

creds = Credentials(
    username='xxxx\\username', 
    password="mypassword"
)

account = Account(
    primary_smtp_address='surname.name@xxxx.fr',
    credentials=creds, 
    autodiscover=True, 
    access_type=DELEGATE
)

# Print first 10 inbox messages in reverse order
for item in account.inbox.all().order_by('-datetime_received')[:10]:
    print(item.subject, item.body, item.attachments)

我尝试使用不同的用户名,但没有任何效果,而且我总是遇到相同的错误消息:

I tried differents usernames but nothing works and I have always the same error message :

AutoDiscoverFailed: All steps in the autodiscover protocol failed

顺便说一句,以防万一它可以帮助我尝试使用为C#编码的Exchange Web服务,并且在这种信誉下工作得很好,我可以发送邮件:

By the way, just in case it could help, i tried to use the Exchange Web service coded for C# and it works perfectly fine with this creds, i can send a mail:

static void Main(string[] args)
{
    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
    // The last parameter is the domain name
    service.Credentials = new WebCredentials("username", "password", "xxxx.lan");
    service.AutodiscoverUrl("surname.name@xxxx.fr", RedirectionUrlValidationCallback);
    EmailMessage email = new EmailMessage(service);
    email.ToRecipients.Add("surname.name@xxxx.fr");
    email.Subject = "salut ";
    email.Body = new MessageBody("corps du message");
    email.Send();
}

private static bool RedirectionUrlValidationCallback(string redirectionUrl)
{
    // The default for the validation callback is to reject the URL.
    bool result = false;

    Uri redirectionUri = new Uri(redirectionUrl);

    /* Validate the contents of the redirection URL. In this simple validation
       callback, the redirection URL is considered valid if it is using HTTPS
       to encrypt the authentication credentials. */
    if (redirectionUri.Scheme == "https")
    {
        result = true;
    }
    return result;
}

提前谢谢!

推荐答案

我终于成功完成了此配置:

I finally succeed with this configuration:

from exchangelib import DELEGATE, Account, Credentials, Configuration

creds = Credentials(
    username="domain_name\\username", 
    password="password"
)

config = Configuration(server='mail.solutec.fr', credentials=creds)

account = Account(
    primary_smtp_address="my email address",
    autodiscover=False, 
    config=config,
    access_type=DELEGATE
)

对于那些将遇到相同问题的用户,您可以通过右键单击计算机"和属性"来找到您的域名. 例如,用户名和密码就是您用来连接到公司邮箱的密码.对于Configuration中的服务器,对我而言,这是有效的:"mail.solutec.fr",其中solutec是我公司的名称,fr在法国.

For those who will have the same problem, you can find your domain_name by right-clicking on "Computer" and Properties. Username and Password are the one you use to connect to your company mailbox for example. For the server in Configuration, for me this one works: "mail.solutec.fr", where solutec is the name of my company and fr for France.

看起来像这个自动发现家伙真的不喜欢我^^

Looks like this autodiscover guy really doesn't like me ^^

感谢您的帮助,祝您有美好的一天!

Thanks for your help anyway and have a good day !

这篇关于exchangelib-自动发现协议中的所有步骤均失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆