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

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 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?