Curl SMTP TLS 错误

标签 c curl

当我运行curl命令时它就起作用了。

但是当我在curl smtp-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

关于Curl SMTP TLS 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26338536/

相关文章:

c - 双向链表不起作用

c - 添加变量时出错

PHP Curl API 响应时间因服务器而异

bash - 如何在curl中加入多个URL输出以传递给jq

json - 在 shell 中处理 json 时,如何正确地将多个 jq 语句链接在一起,例如使用 curl?

c - libcurl (c api) READFUNCTION 用于 http PUT 永远阻塞

c - 两个 32 位数字相乘...这段代码有什么问题

c - 一群人在 c 中使用结构体?

c - Ncurses:刷新非重叠窗口会刷新整个屏幕。如何避免这种情况?

php - 分析 HTML 页面