curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: How to find return code/exit code after sending a mail command

From: Jason Liam via curl-users <curl-users_at_cool.haxx.se>
Date: Sun, 11 Oct 2020 10:09:52 +0530

 So i am using C++ in codeblocks and i have the following code inside a
function for e.g:

char* command = "curl smtp://smtp.gmail.com:587 -v --mail-from xxx_at_gmail.com
--mail-rcpt xxx_at_gmail.com --ssl -u xxx_at_gmail.com:xxx123 -T \"email.txt\" -k
--anyauth";
    int x = WinExec(command, SW_HIDE);
std::cout<<"code" <<x<<std::endl;

And the output on the console shows *code:33*
*Is this the return code of the command.Can i use this to check the success
of the sending process?*I am just learning networking so sorry if this is
pretty basic.

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sun, Oct 11, 2020 at 10:07 AM Jason Liam <jlame646_at_gmail.com> wrote:

> So i am using C++ in codeblocks and i have the following code inside a
> function for e.g:
>
> char* command = "curl smtp://smtp.gmail.com:587 -v --mail-from
> xxx_at_gmail.com --mail-rcpt xxx_at_gmail.com --ssl -u xxx_at_gmail.com:xxx123 -T
> \"email.txt\" -k --anyauth";
> int x = WinExec(command, SW_HIDE);
> std::cout<<"code" <<x<<std::endl;
>
> And the output on the console shows *code:33*
> *Is this the return code of the command.Can i use this to check the
> success of the sending process?*I am just learning networking so sorry if
> this is pretty basic.
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> <#m_6971693422555415978_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Sun, Oct 11, 2020 at 3:25 PM Daniel Stenberg <daniel_at_haxx.se> wrote:
>
>> On Sun, 11 Oct 2020, Jason Liam via curl-users wrote:
>>
>> > I am sending a mail using the command described in the docs and i want
>> to
>> > know the status of the command that is ,Is the mail sent
>> successfully?How
>> > can i do that?
>>
>> when you tell curl to perform something, it will do that. If it fails, it
>> will
>> tell you with an error message and a non-zero exit code.
>>
>> If curl says nothing, you can safely consider the command to have worked.
>>
>> > Below is an example command i am using and the screenshot and i notice
>> that
>> > the connection is left intact.
>>
>> That's a technicality that doesn't mean anything here. It just means that
>> curl
>> *could* have reused the connection again if you would've issued a second
>> command on the same host name.
>>
>> > How can i close the connection after success.
>>
>> It was closed. When curl returns to the shell, there can't be any
>> connection
>> left alive. Never.
>>
>> --
>>
>> / daniel.haxx.se | Commercial curl support up to 24x7 is available!
>> | Private help, bug fixes, support, ports, new features
>> | https://www.wolfssl.com/contact/
>>
>


-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-10-11