【问题标题】:C ++ email not being sent [closed]C ++电子邮件未发送[关闭]
【发布时间】:2020-11-22 13:22:39
【问题描述】:

我无法使用 curl 库发送信件。写入错误不受支持的协议。我使用的是官方网站的标准代码:https://curl.se/libcurl/c/smtp-mail.html 我尝试了不同的选项,没有出现:

curl_easy_setopt (curl, CURLOPT_URL, "smtp://smtp.gmail.com:465");
curl_easy_setopt (curl, CURLOPT_URL, "smtp://smtp.gmail.com");
curl_easy_setopt (curl, CURLOPT_URL, "smtp.gmail.com");
curl_easy_setopt (curl, CURLOPT_URL, "smtp://gmail.com");

错误信息:curl_easy_perform() 失败:不支持的协议

【问题讨论】:

  • 您需要显示minimal reproducible example 而不仅仅是您如何设置选项。
  • 我留了个链接,问题里不能加很多代码
  • @t.niese 实际上在这个特定的例子中,一个最小的可重现的例子并没有多大帮助,问题是他链接的库。 (见下面我的回答)

标签: c++ curl


【解决方案1】:

如果要使用smtp,需要使用--enable-smtp编译的libcurl,例如

./configure --with-ssl --enable-smtp
make -j $(nproc)

您链接的 libcurl 未使用 smtp 支持编译。如果您想知道如何自己编译 libcurl,不妨查看https://stackoverflow.com/a/56394968/1067003

【讨论】:

    猜你喜欢
    • 2012-05-23
    • 2012-04-11
    • 1970-01-01
    • 1970-01-01
    • 2013-04-25
    • 2012-03-04
    • 2013-10-30
    • 2012-08-13
    • 1970-01-01
    相关资源
    最近更新 更多