当我运行curl命令时,它会起作用。
但是当我在curlsmtp-tls.c中运行示例时,我得到了错误。
这是输出。
输出:
Rebuilt URL to: smtp.office365.com:587/
* Hostname was NOT found in DNS cache
* Trying 111.221.114.166...
* Connected to smtp.office365.com (111.221.114.166) port 587 (#0)
< 220 HKNPR03CA002.outlook.office365.com Microsoft ESMTP MAIL Service ready at Mon, 13
Oct 2014 11:00:16 +0000
> EHLO bhagirath-OptiPlex-390
< 250-HKNPR03CA002.outlook.office365.com Hello [14.140.152.42]
< 250-SIZE 78643200
< 250-PIPELINING
< 250-DSN
< 250-ENHANCEDSTATUSCODES
< 250-STARTTLS
< 250-8BITMIME
< 250-BINARYMIME
< 250 CHUNKING
> MAIL FROM:<abc@xyz.com>
< 530 5.7.1 Client was not authenticated
* MAIL failed: 530
> QUIT
* response reading failed
* Closing connection 0
curl_easy_perform() failed: Failed sending data to the peer
请帮忙解决这个问题。
谢谢。
您一定没有为smtp服务器设置用户名\密码。您需要执行以下操作:
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
请参阅文档:https://curl.haxx.se/libcurl/c/smtp-tls.html