我试着用curl和c++发送电子邮件,就像this example一样,但当我执行程序时:

#include <iostream>
#include <curl/curl.h>


int main()
{   
    int a;
    char errbuf[CURL_ERROR_SIZE] = {0};
    CURL *curl = curl_easy_init();
    CURLcode res;
    struct upload_status upload_ctx = { 0 };
    if(curl)
    {   
        curl_easy_setopt(curl, CURLOPT_URL, "smtps://smtp.gmail.com:465");
        curl_easy_setopt(curl, CURLOPT_MAIL_FROM, "");
        curl_easy_setopt(curl, CURLOPT_PASSWORD, "");
        curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, "");
        
        curl_easy_setopt(curl, CURLOPT_READFUNCTION, payload_source);
        curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
        curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
        
        curl_easy_setopt(curl, CURLOPT_CAINFO, "D:\\MinGW\\cacert.pem");
        curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    check_errors(res, errbuf);

    return 0;
}

我得到了这个错误:

curl_easy_perform() failed: Failed sending data to the peer

libcurl: (55) MAIL failed: 530

我删除了大部分代码,因为我不能发布问题,但其余的在示例中。

转载请注明出处:http://www.syyashida.com/article/20230330/2184409.html

随机推荐

  1. 我无法使用angularjs和spring boot mvc连接到数据库

    我正在尝试将AngularJS集成到我的Spring Boot MVC项目中,但是我不明白如何通过@RequestMapping和@GetMapping将它连接到Spring Boot。当我在本地获取项目时,我没有在chrome Googl...

  2. 我无法使用Node.JS服务器连接到SQL server。

    module.exports = { user: ThisUsername, password: ThisPassword, server: 169.254.4.58, database: ThisDatab...

  3. 我无法使用nodejs后端和react前端下载文件

    我正在尝试将请求的文件从前端下载到使用nodejs的后端服务器。在react中,我使用axios,在nodejs中,我使用express。问题是在我的实现中,我得到了以下错误:Error [ERR_STREAM_CANNOT_PIPE]: ...

  4. 我无法使用谷歌搜索控制台或PageSpeedInsights加载或爬行我的网站

    当我添加我的网站域名:https://tayninh.gov.vn/时,谷歌搜索控制台和Goolge Pagespeedinsights都显示错误,如: Lighthouse error: FAILED_DOCUMENT_REQUEST。灯...

  5. 我无法使用dagger 2将存储库注入ViewModel

    我创建自定义ViewModelProvider.Factory@Singleton public class ViewModelFactory implements ViewModelProvider.Factory { priv...

  6. 我无法使用xpath和IMPORTXML访问网站中的数据,因为代码片段在源数据之外

    我想从以下网站获取数据:https://www.portaldefinancas.com/framecdi.htm我正在使用带有IMPORTXML函数的google sheets。我学习了一点关于xpath的知识,我相信我的问题不是语法。问...

  7. 我无法使用npx创建react应用程序

    我在windows中创建React应用程序时遇到了问题,希望你们能帮助我。我已经用超级终端npx create-react-app new-app编写了这个命令,并且我检查了我的node.js版本是12.16.1,我的npm版本和npx版本...

  8. 我无法使用label.configure更改图像

    我正在尝试创建一个可以在其中处理图像的GUI,因此我必须将默认图像更改为浏览按钮选择的图像。默认图像将消失,但新图像不会出现。请帮帮我!下面是我的代码:from Tkinter import * from tkFileDialog impo...

  9. 我无法使用curl访问所需的url。

    我试着卷曲一个网站,在我的网站上展示它,但我总是停留在一个白色页面。我想是因为它有一个重定向到一个登录表单,但我不确定是否是因为我失败了。您无需登录即可访问我使用的url。下面是代码$url = http://www.faf.es/pnfg...

  10. 我无法使用peerjs Webrtc在Safari浏览器上接收或发送视频流

    我已经建立了他们的例子,他们为peerjs是工作得很好,我的电脑上的chrome,但我有ipad pro与safari v12,是只给我本地流,但不是发送回的答案给发送者对等这是我的发件人客户端const peer = new Peer(s...