Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7992907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:42:19+00:00 2026-06-04T13:42:19+00:00

I’m trying to send a simple text mail to my email account but for

  • 0

I’m trying to send a simple text mail to my email account but for some reason my code is not working. This is what i haev so far…

int SendStartUpMail(char* mailserver, int port, char* user, char* pass)
{
     SOCKET sslSock;
     SOCKADDR_IN sslInfo;
     SSL_CTX *ctx;
     SSL *ssl;

     char bufferRecv[BUFFER_LEN];
     char bufferSend[BUFFER_LEN];
     int byte;

     sslSock = openConnection(mailserver, port);
     memset( bufferRecv, '\0', BUFFER_LEN );
     byte = recv(sslSock,bufferRecv,BUFFER_LEN,0);
     if(byte == SOCKET_ERROR)
         return -1;
     printf("%s\n",bufferRecv);

     strcpy(bufferSend,"HELO\r\n");
     send(sslSock,bufferSend,strlen(bufferSend),0);
     memset( bufferRecv, '\0', BUFFER_LEN );
     byte = recv(sslSock,bufferRecv,BUFFER_LEN,0);
     if(byte == SOCKET_ERROR)
         return -1;
     printf("%s",bufferRecv);

     strcpy(bufferSend,"STARTTLS\r\n");
     send(sslSock,bufferSend,strlen(bufferSend),0);
     memset( bufferRecv, '\0', BUFFER_LEN );
     byte = recv(sslSock,bufferRecv,BUFFER_LEN,0);
     if(byte == SOCKET_ERROR)
          return -1;
     printf("%s",bufferRecv);

     SSL_library_init();
     ctx = SSL_CTX_new(SSLv3_client_method());
     if ( ctx == NULL )
         return -1;
     ssl = SSL_new(ctx);
     if ( ssl == NULL )
         return -1;
     SSL_set_fd(ssl, sslSock);  

     if ( SSL_connect(ssl) == 1 )
     {
         strcpy(bufferSend,"HELO\r\n");
         SSL_write(ssl,bufferSend,strlen(bufferSend));
         memset( bufferRecv, '\0', BUFFER_LEN );
         SSL_read(ssl,bufferRecv,BUFFER_LEN);
         printf(">%s\n",bufferRecv);

         strcpy(bufferSend,"AUTH LOGIN\r\n");
         SSL_write(ssl,bufferSend,strlen(bufferSend));
         memset( bufferRecv, '\0', BUFFER_LEN );
         SSL_read(ssl,bufferRecv,BUFFER_LEN);
         printf(">%s\n",bufferRecv);

         strcpy(bufferSend,"USER c29tZXVzZXJuYW1lQGdtYWlsLmNvbQ==\r\n");         
         SSL_write(ssl,bufferSend,strlen(bufferSend));
         memset( bufferRecv, '\0', BUFFER_LEN );
         SSL_read(ssl,bufferRecv,BUFFER_LEN);
         printf(">%s\n",bufferRecv);

         strcpy(bufferSend,"PASS c29tZXBhc3N3b3Jk\r\n");         
         SSL_write(ssl, bufferSend,strlen(bufferSend));
         memset( bufferRecv, '\0', BUFFER_LEN );
         SSL_read(ssl,bufferRecv,BUFFER_LEN);
         printf(">%s\n",bufferRecv);
     }
     else
     {
         printf("Error on SSL_connect\n");  
         SSL_free(ssl);
         SSL_CTX_free(ctx);
         close(sslSock); 
         return -1; 
     }
     SSL_free(ssl); 
     SSL_CTX_free(ctx);
     close(sslSock);

}

When i run this code i get some messages from the smtp server:

> 220 mx.google.com ESMTP 
> 250 mx.google.com at your service
> 220 2.0.0 Ready to Start TLS
> Conected with RC4-SHA encryption
> 250 mx.google.com at your service
> 334
> 334
> 535-5.7.1 Useername and Password not accepted

as you can see they say my password and username are wrong, but i know, it’s not wrong.
im using base64 encoding to encode my username and password before sending,i used this site to encode them http://base64-encoder-online.waraxe.us/
I use port 587.

My question is there something else i have to do???
Thanks.

I also tried using the Google two-step verification for application specific password and it still wont login.

I tried to connect to hotmail instead and got a different error,instead of error 535 i get

451 Request action aborted: local error in processing

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:42:20+00:00Added an answer on June 4, 2026 at 1:42 pm

    Testing with my own account, AUTH LOGIN doesn’t work, but AUTH PLAIN works just fine:

    250 ENHANCEDSTATUSCODES
    auth plain
    334 
    c29tZXVzZXJAZ21haWwuY29tAHNvbWV1c2VyQGdtYWlsLmNvbQBzb21lcGFzc3dvcmQ=
    235 2.7.0 Accepted
    

    That’s the base64-encoded version of someuser@gmail.com\x00someuser@gmail.com\x00somepassword.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.