不想说话(努力写buging) 2023-01-23 23:35 采纳率: 83.3%
浏览 57
已结题

C语言程序最终返回值3221225477

C语言程序最终返回值3221225477
代码如下,部分参数涉及隐私,已做处理
#include <stdio.h>
#include "curl/curl/curl.h"
#include <string.h>
#include <Windows.h>
int send_email(char *from, char *to, char *subject, char *body, char *username, char *password)
{
    CURL *curl;
    CURLcode res = CURLE_OK;
    struct curl_slist *recipients = NULL;
    struct curl_slist *headers = NULL;
    char data[1000]={0}; 
    snprintf(data, 500, "from=%s&to=%s&subject=%s&body=%s&username=%s&password=%s", from, to, subject, body, username, password);
    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_CAINFO, "cacert.pem");
        curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
        curl_easy_setopt(curl, CURLOPT_URL, "smtp://smtp.163.com");
        curl_easy_setopt(curl, CURLOPT_USERNAME, username);
        curl_easy_setopt(curl, CURLOPT_PASSWORD, password);
        curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=LOGIN");
        curl_easy_setopt(curl, CURLOPT_MAIL_FROM, from);
        recipients = curl_slist_append(recipients, to);
        curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
        curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_READDATA, data);
        curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
        res = curl_easy_perform(curl);
        if(res != CURLE_OK){
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        }
        else
            printf("%s","success");
        curl_slist_free_all(recipients);
        curl_easy_cleanup(curl);
    }
    return (int)res;
}

int main(void)
{
    int result;
    result = send_email("@163.com", "95@qq.com", "Test Email", "This is a test email.", "@163.com", "VGBBBSF");
    system("pause");
}

终端运行
< 235 Authentication successful
> MAIL FROM:<@163.com>
< 250 Mail OK
> RCPT TO:<@qq.com>
< 250 Mail OK
> DATA
< 354 End data with <CR><LF>.<CR><LF>

--------------------------------
Process exited after 3.421 seconds with return value 3221225477
请按任意键继续. . .

  • 写回答

1条回答 默认 最新

报告相同问题?

问题事件

  • 系统已结题 2月1日
  • 已采纳回答 1月24日
  • 创建了问题 1月23日

悬赏问题

  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含