Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[help] sending email via C++

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Nov 23, 2008 1:20 pm    Post subject: [help] sending email via C++ Reply with quote

i'm trying to send an email via C++ using sockets
well my code hasn't got any error but it doesn't sends any mail
that's my code, i thought that i might wrong at the sockaddr_in thing so correct me if there's any problem there
Code:

#define br cout << "\n";

char Buffer[260] = "";
char RecvBuff[260] = "";

void main()
{
   sockaddr_in addr;
   addr.sin_family = AF_INET;
   addr.sin_addr.s_addr = inet_addr("66.249.93.111"); //smtp.gmail.com ip
   addr.sin_port = htons(25);
   WSADATA wsaData;
   if (WSAStartup(MAKEWORD(1,1),&wsaData) != 0){
      cout << "[!] WSAStartup failed";
      br;
   }
   int sock;
   cout << "[!] Connecting...";
   br;
   sock = socket(AF_INET,SOCK_STREAM,0);
   if (sock == -1){
      cout << "[!] socket failed";
      br;
   }
   if (connect(sock,(struct sockaddr *)&addr,sizeof(addr)) == -1){
      cout << "[!] connect failed";
      br;
   }
   cout << "[!] Connected";
   br;
   strcpy(Buffer,"HELO smtp.gmail.com");
   if (send(sock,Buffer,strlen(Buffer),0) == -1){
      cout << "[!] send1 failed";
      br;
   }
   if (recv(sock,RecvBuff,strlen(RecvBuff),0) == -1){
      cout << "[!] recv1 failed";
      br;
   }
   cout << "[!] " << RecvBuff;
   br;
   Sleep(1000);
   strcpy(Buffer,"MAIL FROM :<gmailEmail>");
   if (send(sock,Buffer,strlen(Buffer),0) == -1){
      cout << "[!] send2 failed";
      br;
   }
   if (recv(sock,RecvBuff,strlen(RecvBuff),0) == -1){
      cout << "[!] recv2 failed";
      br;
   }
   cout << "[!] " << RecvBuff;
   br;
   Sleep(1000);
   strcpy(Buffer,"RCPT TO:< gmailEmail >");
   if (send(sock,Buffer,strlen(Buffer),0) == -1){
      cout << "[!] send3 failed";
      br;
   }
   if (recv(sock,RecvBuff,strlen(RecvBuff),0) == -1){
      cout << "[!] recv3 failed";
      br;
   }
   cout << "[!] " << RecvBuff;
   br;
   Sleep(1000);
   strcpy(Buffer,"DATA\nHello\n.");
   if (send(sock,Buffer,strlen(Buffer),0) == -1){
      cout << "[!] send4 failed";
      br;
   }
   if (recv(sock,RecvBuff,strlen(RecvBuff),0) == -1){
      cout << "[!] recv4 failed";
      br;
   }
   cout << "[!] " << RecvBuff;
   br;
   Sleep(1000);
   strcpy(Buffer,"QUIT");
   if (send(sock,Buffer,strlen(Buffer),0) == -1){
      cout << "[!] send5 failed";
      br;
   }
   if (recv(sock,RecvBuff,strlen(RecvBuff),0) == -1){
      cout << "[!] recv5 failed";
      br;
   }
   cout << "[!] " << RecvBuff;
   br;
   Sleep(1000);
   cin.get();
}

any suggestions?

_________________
Stylo
Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Mon Nov 24, 2008 3:17 am    Post subject: Reply with quote

http://mail.google.com/support/bin/answer.py?hl=en&answer=13287 wrote:
Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use authentication)
Use Authentication: Yes
Use STARTTLS: Yes (some clients call this SSL)
Port: 465 or 587

You need to implement SSL and authenticate with your gmail account before an email can be sent through their server. I'm not really sure about the specifics, but you might want to start with OpenSSL / cryptlib.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon Nov 24, 2008 4:50 am    Post subject: Reply with quote

how would i implement SSL in my code?
i mean i read what you've gave, but i didn't understand how can i impelemt it inside my code ?!

_________________
Stylo
Back to top
View user's profile Send private message
SXGuy
I post too much
Reputation: 0

Joined: 19 Sep 2006
Posts: 3551

PostPosted: Mon Nov 24, 2008 8:46 am    Post subject: Reply with quote

From what i understand, sending mail through gmail is very complicated.

As already mentioned, you need SSL or it wont work.

You may find it easy, to use a free SMTP forwarding host.

What you do is, send mail to one of the SMTP hosts, and they redirect it to your gmail account or any account you like.

That way you need no SSL's, no authentication process.

The hardest part, is finding a free smtp host that allows you to redirect mail.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon Nov 24, 2008 9:18 am    Post subject: Reply with quote

so what if i'd want to send to a hotmail address? or any other server besides gmail?
would it be that complicated?

_________________
Stylo
Back to top
View user's profile Send private message
SXGuy
I post too much
Reputation: 0

Joined: 19 Sep 2006
Posts: 3551

PostPosted: Mon Nov 24, 2008 9:28 am    Post subject: Reply with quote

yes, alot of them now, do not allow SMTP connections without SSL.

Ever thought about scrapping it all and just using TCP to send data instead?
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon Nov 24, 2008 9:55 am    Post subject: Reply with quote

actually i'm pretty new to this mailing stuff so i don't really know much about what you're talking
so if you can explain more or point me to a good tutorial / explanation it'd be great
i'm searching at google for tutorials and i found this thing
http://www.example-code.com/vcpp/c++_smtp_ssl.asp
i downloaded the whole package they put there
but i don't know how to use it in my project

_________________
Stylo
Back to top
View user's profile Send private message
SXGuy
I post too much
Reputation: 0

Joined: 19 Sep 2006
Posts: 3551

PostPosted: Mon Nov 24, 2008 10:10 am    Post subject: Reply with quote

yeah what you posted is fine, although its set up to use a domain name email address with smtp functionality.

But you would just replace that with an smtp host, which redirects the mail automatically to gmail.

search google for free smtp, and check if any of them allow mail forwarding
Back to top
View user's profile Send private message
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Mon Nov 24, 2008 11:51 am    Post subject: Reply with quote

I was writing a PHP form mailer about a year ago, and had no SMTP mail account, so I tried to use my gmail account and found out that gmail uses (used?) a funky non-standard implementation. I found some hacky specialized code online to handle it. That might be associated with your issue.
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Mon Nov 24, 2008 12:09 pm    Post subject: Reply with quote

1qaz wrote:
actually i'm pretty new to this mailing stuff so i don't really know much about what you're talking
so if you can explain more or point me to a good tutorial / explanation it'd be great
i'm searching at google for tutorials and i found this thing
http://www.example-code.com/vcpp/c++_smtp_ssl.asp
i downloaded the whole package they put there
but i don't know how to use it in my project

Code:
// Send email via an SSL connection with an SMTP server.
void SendEmailSsl(void)
    {
    CkMailMan mailman;
    mailman.UnlockComponent("Anything for 30-day trial");

    // Create a simple email for sending.
    CkEmail email;
    email.put_Body("This is a test");
    email.put_Subject("Test email for SMTP SSL");
    email.put_From("Chilkat Support <[email protected]>");
    email.AddTo("Matt","[email protected]");

    // The SMTP SSL port is usually 465.
    mailman.put_SmtpSsl(true);
    mailman.put_SmtpPort(465);

    // Set our SMTP hostname and login/password info.
    // The login/password may or may not be necessary depending on your server
    // and on the location from which you are connecting (i.e. depending on whether
    // you may be inside or outside of a firewall, if one exists.)
    mailman.put_SmtpHost("mail.chilkatsoft.com");
    mailman.put_SmtpUsername("myLogin");
    mailman.put_SmtpPassword("myPassword");

    bool success = mailman.SendEmail(&email);
    if (!success)
   {
   mailman.SaveLastError("sendError.txt");
   }

    return;
    }


What do'nt you understand about that? It tells you exactly what to do

_________________
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon Nov 24, 2008 12:38 pm    Post subject: Reply with quote

@blankrider
it's not the code itself
it's just when i add the headers files to my projects and building the solution
i get all this wierd errors (something like 100 errors) that i don't understand what i do wrong
plus it doesn't say what libraries i need to include in the project so i guess that's the reason for the errors

_________________
Stylo
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites