cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Why syntax error in release version of code in visual c++

From: ansh kumar <anshgravity_at_gmail.com>
Date: Thu, 6 Feb 2014 18:10:03 +0530

Okay I've removed \0 from the buffer size.
1) I want to know why I'm getting following error if I use
CURLOPT_INFILESIZE_LARGE option instead of CURLOPT_INFILESIZE :

> MAIL FROM:<xxxx_at_gmail.com> SIZE=141949047089924518
< 555 5.5.2 Syntax error. hb10sm2446415pbd.1 - gsmtp
* MAIL failed: 555

2) I've downloaded whole of the cacert.pem from the curl website, but I
only want the certificate for using gmail. How to get its certificate ?

I'll be trying std::string. Thax for the suggestion.

On Thu, Feb 6, 2014 at 4:41 AM, Steve Holme <steve_holme_at_hotmail.com> wrote:

> On Wed, 5 Feb 2014, ansh kumar wrote:
>
> > * Connection #0 to host smtp.gmail.com left intact
> > > QUIT
> > < 221 2.0.0 closing connection iu7sm77803912pbc.45 - gsmtp
> > * Closing connection #0
> >
> > Is it some kind of error or what?
>
> From what I remember of the pre-multi work of January 2013 yes that looks
> correct.
>
> In SMTP terms a QUIT is always sent to terminate the connection. However,
> because the easy interface now uses the multi-interface underneath you
> don't
> currently see that QUIT with curl 7.29 and above :(
>
> > And my code is in the attachment.
> >
> > strcpy(fileBuf[len++],"To: " TO "\r\n");
> > buffer_size += strlen(fileBuf[len-1]) + 1; // 1 for \0
>
> Why are you adding one for the null to the buffer_size, which you then pass
> to curl as the INFILESIZE?? That doesn't seem right to me and looks like
> you
> are telling curl to tell the email server the incorrect size of the email -
> admittedly by only a few bytes but still the wrong size.
>
> As you are using STL elsewhere in your code, I would recommend using a
> std::string for the payload along with a character count rather than an
> array of fixed length lines with a line counter. For example:
>
> struct fileBuf_upload_status
> {
> std::string payload;
> size_t counter;
> };
>
> Then in your fileBuf_source() function you can do something like:
>
> static size_t fileBuf_source(void *ptr, size_t size, size_t nmemb, void
> *userp)
> {
> struct fileBuf_upload_status *upload_ctx = (struct
> fileBuf_upload_status
> *)userp;
>
> size_t len = std::min(payload.length() - upload_ctx->counter, size *
> nmemb);
> if(len > 0)
> {
> memcpy(ptr, upload_ctx->payload.c_str() + upload_ctx->counter,
> len);
> upload_ctx->counter += len;
> }
>
> return len;
> }
>
> That way you a) don't have to let curl call your callback so many times,
> but
> instead can fill the buffer up as much as possible - for example up to 16k,
> b) don't have to have a blank line to signify the end of the data c) have
> fixed row length lines of 200 characters and d) don't have to dynamically
> allocate your fileBuf - just let STL do the work for you ;-) In that
> respect
> the examples are written as simple examples without any other libraries
> such
> as STL in mind.
>
> Saying that... email clients tend to limit the length of each line to 78
> characters including the \r\n - just take a look at your email with POP3
> and
> you'll see that headers span multiple rows because of this and base64 and
> quoted printable encoded attachments and inline images will be wrapped at
> 76
> characters ;-)
>
> Kind Regards
>
> Steve
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-02-06