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 8129791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:26:16+00:00 2026-06-06T08:26:16+00:00

I just started with the Poco library and tried to create an email program

  • 0

I just started with the Poco library and tried to create an email program (Which I knew virtually nothing about). The following is my code (There may be other problems with it besides the one I’ve encountered so far, but I just started working on it)

    int main(int argc, char** argv)
{
    Poco::Net::SocketAddress add("smtp.gmail.com:465");
    Poco::Net::StreamSocket sock(add);
    Poco::Net::SMTPClientSession sess(sock);
    std::cout << "-";
    sess.login(
            "gmail.com",
            Poco::Net::SMTPClientSession::AUTH_LOGIN,
            "----",
            "----"
    );
    Poco::Net::MailMessage msg;
    Poco::Net::MailRecipient resp(Poco::Net::MailRecipient::PRIMARY_RECIPIENT,"michaelrgoldfine@gmail.com");
    msg.addRecipient(resp);
    std::string content("HELP SOS");
    msg.encodeWord(content);
    std::cout << msg.getContent() << "-";
}

When I go into the debugger, it runs fine until it gets to sess.login then suddenly the little bar that represents were I am in the code disappears but the program keeps running (I’m not experienced enough to know what that means). None of the cout stuff I put in actually prints, the debugger just goes past that line but nothing shows up. After a little while this comes up:

terminate called throwing an exception

So what’s going on?

  • 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-06T08:26:17+00:00Added an answer on June 6, 2026 at 8:26 am

    You are attempting to use SMTP over TLS (the port 465 passed to the SocketAddress). In one shot you have to learn (1) TLS and certificate handling in POCO, before focusing on (2) your goal: sending an email message.

    I suggest to start learning POCO with simpler examples. You can find sample code in the various samples directories in the POCO source code.

    I think that your code is just hanging on the TLS handshake, because it doesn’t know what to do.

    These are the fixes you should do before looking at the solution:

    1. Place your code inside a try/catch block. POCO uses exceptions.
    2. Replace StreamSocket with SecureStreamSocket.
    3. The simplest way to properly initialize SecureStreamSocket is via the Application class. See the Applications slides and Util/samples/SampleApp/src/SampleApp.cpp.
    4. See the documentation for the SSLManager for how to properly tell the Application which certificates to use.
    5. Don’t specify an hostname to the login() method. The hostname is optional and should be the client hostname, not the server (See the SMTP RFC).
    6. Remember to actually send the message! Your code is not sending it 🙂

    OK, and now for the running code. I left steps 4 and 6 as an exercise, but this code will at least run the TLS handshake, will tell you that it cannot verify the server’s certificate and, if you answer Yes on the terminal to the questions on the certificates, it will fail the SMTP authentication.

    class MiniApp : public Poco::Util::Application {
        int main(const vector <string>& args) {
            try {
                Poco::Net::SocketAddress add("smtp.gmail.com:465");
                Poco::Net::SecureStreamSocket sock(add);
                Poco::Net::SMTPClientSession session(sock);
                session.login(Poco::Net::SMTPClientSession::AUTH_LOGIN, "user", "pw");
                Poco::Net::MailMessage msg;
                Poco::Net::MailRecipient recipient(Poco::Net::MailRecipient::PRIMARY_RECIPIENT,
                                        "michaelrgoldfine@gmail.com");
                msg.addRecipient(recipient);
                string content("HELP SOS");
                msg.encodeWord(content);
            } catch (Poco::Exception& e) {
                cout << "Error: " << e.displayText() << endl;
                return -1;
            }
            return 0;
        }
    };
    
    POCO_APP_MAIN(MiniApp)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just started trying to integrate the Poco C++ Library with our game engine,
just started using log4j in one of my home-projects and I was just about
Just started looking at some MVC JS framework / library and most of them
Just started doing some code porting from .Net CF to Blackberry JDE 4.6.1. But
Just started converting to MVC from classic ASP and wondering about best practice for
Just started learning NServiceBus and trying to understand the concept. When it talks about
Just started to develop for Android, the idea is to create an app available
Just started playing with knockout.Js which is a fantastic framework Steve's really done well
I just started trying my hands on EF4 code first this morning and I
Just started testing nodejs, and wanted to get some help in understanding following behavior:

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.