C++ CURL Library for Sending Emails
Morgatte
Posted messages
1300
Status
Member
-
Morgatte Posted messages 1300 Status Member -
Morgatte Posted messages 1300 Status Member -
Hello,
Could someone help me? I'm trying to send emails using the cURL library, but I'm having trouble with the authentication step.
Configuration: Win10 & Debian and Ubuntu (Latest versions)
Portable XPS15
--
(Desperate Housewives)
We are not even playing in the same league that I wonder if we are practicing the same sport.
Could someone help me? I'm trying to send emails using the cURL library, but I'm having trouble with the authentication step.
Configuration: Win10 & Debian and Ubuntu (Latest versions)
Portable XPS15
--
(Desperate Housewives)
We are not even playing in the same league that I wonder if we are practicing the same sport.
1 answer
-
I just found a first success in sending an email.
Here’s how to do it:
You must first have curl.exe and its DLLs on your computer.
Then by typing this in cmd.exe I can send an email in authenticated mode (SSL)
curl smtps://smtp.laposte.net:465 -v --mail-from "monMail@laposte.net" --mail-rcpt "destinataire@hotmail.com" --ssl -u monMail@laposte.net:MonCodeMail -T "text.txt" -k --anyauth
With the content of the text file as follows:
-----------------
From: "The name I want" <monMail@laposte.net>
To: "recipient" <destinataire@hotmail.com>
Subject: This is the subject
Hi,
I just sent an email using the cURL library from the command line
Bye!
-----------------
Last step, I need to manage to rewrite the equivalent of this line in C++ using the various cURL functions.
Like:
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
curl_easy_setopt(curl, CURLOPT_USERNAME, "monMail@laposte.net");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "motDePassMail");
curl_easy_setopt(curl, CURLOPT_URL, "smtps://smtp.laposte.net");
curl_easy_setopt(curl, CURLOPT_PORT, 465);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);
recipients = curl_slist_append(recipients, TO);
recipients = curl_slist_append(recipients, CC);
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
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_VERBOSE, 1L);
/* Send the message */
res = curl_easy_perform(curl);
And it’s still not won!
(Desperate Housewives)
We’re not even playing in the same division that I wonder if we’re practicing the same sport.-
Petite erreur dans ma ligne de code... Je pose donc le bon code...
curl smtps://smtp.laposte.net:465 -v --mail-from "Expediteur@laposte.net" --mail-rcpt "destinataire@hotmail.com" --ssl -u Expediteur:motdepasse -T "text.txt" -k --anyauth
-----------------
From: "Le nom que je veux" <Expediteur@laposte.net>
To: "destinataire" <destinataire@hotmail.com>
Subject: Ceci est le sujet
Salut,
Je viens d'envoyer un email a partir de la librairie cURL en ligne de commande
Bye!
-----------------
-