Emailing Passwords

Pages: 12
Jan 10, 2015 at 5:28pm
Ok, so I need to make a program that prompts the user for their Username: and their Password: I know how to read in from a text file but the key here is I need the users inputs, to be E-mailed to me. I need to figure out some way in the coding to have it like link the input to my specified email. I don't know if anybody knows how to do this in c++, but any help will be greatly appreciated!
Jan 10, 2015 at 6:19pm
Umm this seems a bit suspicious but anyways you may need to use external library or I think there was a recent thread about sending email in c++ without external library
Jan 10, 2015 at 6:20pm
Ok lol, this is for a science fair project that shows the dangers of cyber security by the way :) And do you have a link to that thread?
Jan 10, 2015 at 6:36pm
http://www.cplusplus.com/forum/beginner/152335/ is the most recent.


Anyways, there are several out there.
http://www.cplusplus.com/search.do?q=send+email+2014


This would be one with an external library
http://www.example-code.com/vcpp/smtp_simpleSend.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <CkMailMan.h>
#include <CkEmail.h>

void ChilkatSample(void)
    {
    //  The mailman object is used for sending and receiving email.
    CkMailMan mailman;

    //  Any string argument automatically begins the 30-day trial.
    bool success;
    success = mailman.UnlockComponent("30-day trial");
    if (success != true) {
        printf("%s\n",mailman.lastErrorText());
        return;
    }

    //  Set the SMTP server.
    mailman.put_SmtpHost("smtp.chilkatsoft.com");

    //  Set the SMTP login/password (if required)
    mailman.put_SmtpUsername("myUsername");
    mailman.put_SmtpPassword("myPassword");

    //  Create a new email object
    CkEmail email;

    email.put_Subject("This is a test");
    email.put_Body("This is a test");
    email.put_From("Chilkat Support <support@chilkatsoft.com>");
    email.AddTo("Chilkat Admin","admin@chilkatsoft.com");
    //  To add more recipients, call AddTo, AddCC, or AddBcc once per recipient.

    //  Call SendEmail to connect to the SMTP server and send.
    //  The connection (i.e. session) to the SMTP server remains
    //  open so that subsequent SendEmail calls may use the
    //  same connection.
    success = mailman.SendEmail(email);
    if (success != true) {
        printf("%s\n",mailman.lastErrorText());
        return;
    }

    //  Some SMTP servers do not actually send the email until
    //  the connection is closed.  In these cases, it is necessary to
    //  call CloseSmtpConnection for the mail to be  sent.
    //  Most SMTP servers send the email immediately, and it is
    //  not required to close the connection.  We'll close it here
    //  for the example:
    success = mailman.CloseSmtpConnection();
    if (success != true) {
        printf("Connection to SMTP server not closed cleanly.\n");
    }

    printf("Mail Sent!\n");
    }


Here is another example without library
http://www.marshallsoft.com/c-email-example.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// C/C++ Email Example 

#include <windows.h>
#include <stdio.h>
#include "see.h"

// connect to SMTP server then send email

int SendMail(char *ToList, char *Subject, char *Message)
{int Code;
 char *SmtpHost = "smtp.my-isp.com";
 char *SmtpUser = "my-user-name";
 char *SmtpPass = "my-password";
 char *SmtpFrom = "<mike@my-isp.com>"
 char *SmtpReply= "<mike@my-isp.com>"
 char *ccList = NULL;
 char *bccList = NULL;
 char *Attachments = NULL;
 // specify the port to connect on (default port is 25)
 seeIntegerParam(0, SEE_SMTP_PORT, 587);
 // enable "SMTP Authentication"
  seeIntegerParam(0, SEE_ENABLE_ESMTP, 1);
 // specify the user name and password for SMTP authentication
 seeStringParam(0, SEE_SET_USER, SmtpUser);
 seeStringParam(0, SEE_SET_SECRET, SmtpPass);
 // connect to SMTP server
 Code = seeSmtpConnect(0, SmtpHost, SmtpFrom, SmtpReply);
 // error ? (negative return codes are errors)
 if(Code<0) return Code;
 // send email to list of recipients (ToList)
 Code = seeSendEmail(0,ToList,ccList,bccList,Subject,Message,Attachments);
}
Last edited on Jan 10, 2015 at 6:37pm
Jan 11, 2015 at 4:16pm
Could you explain the one without libraries, becuase i know the #include <windows.h>, I have used #include <stdio.h>, a few times but am not familiar with it, but have never used #include "see.h"
Jan 11, 2015 at 9:53pm
stdio is the old c input/output and sorry didn't realize the see header. That looks to be an external library as well.
Jan 12, 2015 at 3:44am
Um, you should at least encrypt the information you are sending via email if it is a username and password.
Jan 12, 2015 at 12:53pm
Ummm, I have no idea how to encrypt them lol, and i don't need to, this is for a science fair project on Cyber Security so its NOT for malicious intent xD
Jan 12, 2015 at 7:31pm
...so... you are doing a science fair project on cyber security showing how to send plain-text usernames and passwords through the email?

...

Use Boost ASIO and SSL.
http://www.boost.org/doc/libs/release/doc/html/boost_asio.html

Be warned, what you are asking to do is not simple.
Also:
http://stackoverflow.com/questions/24752823/boost-asio-ssl-simple-encryption-program

Good luck!
Jan 12, 2015 at 7:54pm
> showing how to send plain-text usernames and passwords through the email?
I thought that the point was http://xkcd.com/792/
Jan 13, 2015 at 9:03pm
What is the boost asio? and yes im aware that is not a simple thing to do. And the science fair project does not consist of just an emailing program. This is just a great demonstration to do.
Jan 13, 2015 at 10:31pm
What is the boost asio?
http://www.boost.org/
Jan 15, 2015 at 2:12pm
Ok, can anyone send me the external file libraries for #include "see.h" ?
Jan 16, 2015 at 1:17am
Jan 17, 2015 at 4:05pm
Oh, thanks, but once I download it, under which folder do I put this in?
Jan 21, 2015 at 6:01pm
Which folder to the header files go in? Because I found my Dev C++ folder, but there are multiple folders there, so where do I drag and drop this one into?
Jan 22, 2015 at 1:15am
You can save the folder where ever you want it to. If it is header only then you can simply include the header. If it is in library format you will need to link the library then include any necessary headers.
Jan 22, 2015 at 5:10pm
Ok thanks
Jan 22, 2015 at 5:57pm
@ OP: I would encourage you to at least read over ESMTP, it's not as difficult as most people make it out to be. You are just passing text back and forth after all. Even TLS is shockingly easy (once you get the hang of the basics) because MS's CryptoAPI handles the heavy lifting for you. That's not to say that Boost is a bad suggestion, it just isn't really a beginner library.
Jan 22, 2015 at 6:33pm
Ok, but now I'm having a problem... I need an IDE for c++ since my dev c++ says no binary directories found; aborting compilation. Every one I try to download, will NOT run the .exe file for it to start... HELP
Pages: 12