这是我的libcurl代码。我正在尝试在Linux中将电子邮件发送到我自己的电子邮件域。尝试使用libcurl发送电子邮件的证书问题
这是我的示例libcurl代码。
curl_easy_setopt(curl, CURLOPT_USERNAME, "[email protected]");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "mypassword");
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.mydomain.com:25");
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
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_INFILESIZE, file_size);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, fileBuf_source);
curl_easy_setopt(curl, CURLOPT_READDATA, &file_upload_ctx);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); //Dont display Curl Connection data Change 1L to 0
res = curl_easy_perform(curl);
当我运行此代码时,出现以下错误。
* Rebuilt URL to: smtp://mail.mydomain.com:25/
* Hostname was NOT found in DNS cache
* Trying <My mail domain Ip address>...
* Connected to mail.mydomain.com (<My mail domain Ip address>) port 25 (#0)
< 220 mail.mydomain.com ESMTP
> EHLO client6
< 250-mail.mydomain.com
< 250-PIPELINING
< 250-SIZE 20480000
< 250-VRFY
< 250-ETRN
< 250-STARTTLS
< 250-AUTH PLAIN LOGIN
< 250-ENHANCEDSTATUSCODES
< 250-8BITMIME
< 250 DSN
> STARTTLS
< 220 2.0.0 Ready to start TLS
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSL certificate problem: self signed certificate
* Closing connection 0
curl_easy_perform() failed: Peer certificate cannot be authenticated with given CA certificates