Overview
Features
Download
Documentation
Community
Add-Ons & Services

Missing definition for MailMessage in SMTPClientSession.h?

Please post support and help requests here.

Missing definition for MailMessage in SMTPClientSession.h?

Postby xcdemon05 » 22 Feb 2014, 19:12

I'm very new to installing libraries so I might have made a mistake when installing this one. I am using Visual Studio 2013, and I'm trying to use Poco to create an email sending program (to send myself updates about my friend's sporting events). Anyways, I followed the installation instructions and it seems like everything installed okay except for one thing. In the file SMTPClientSession.h, I have the following (i got rid of the comments at the top of the file):

Code: Select all

#ifndef Net_SMTPClientSession_INCLUDED
#define Net_SMTPClientSession_INCLUDED


#include "Poco/Net/Net.h"
#include "Poco/Net/DialogSocket.h"
#include "Poco/DigestEngine.h"
#include "Poco/Timespan.h"


namespace Poco {
namespace Net {


class MailMessage;



class Net_API SMTPClientSession
   /// This class implements an Simple Mail
   /// Transfer Procotol (SMTP, RFC 2821)
   /// client for sending e-mail messages.
{
public:
   enum
   {
      SMTP_PORT = 25
   };

   enum LoginMethod
   {
      AUTH_NONE,
      AUTH_CRAM_MD5,
      AUTH_CRAM_SHA1,
      AUTH_LOGIN,
      AUTH_PLAIN
   };

   explicit SMTPClientSession(const StreamSocket& socket);
      /// Creates the SMTPClientSession using
      /// the given socket, which must be connected
      /// to a SMTP server.

   SMTPClientSession(const std::string& host, Poco::UInt16 port = SMTP_PORT);
      /// Creates the SMTPClientSession using a socket connected
      /// to the given host and port.

   virtual ~SMTPClientSession();
      /// Destroys the SMTPClientSession.

   void setTimeout(const Poco::Timespan& timeout);
      /// Sets the timeout for socket read operations.
      
   Poco::Timespan getTimeout() const;
      /// Returns the timeout for socket read operations.

   void login(const std::string& hostname);
      /// Greets the SMTP server by sending a EHLO command
      /// with the given hostname as argument.
      ///
      /// If the server does not understand the EHLO command,
      /// a HELO command is sent instead.
      ///
      /// Throws a SMTPException in case of a SMTP-specific error, or a
      /// NetException in case of a general network communication failure.

   void login();
      /// Calls login(hostname) with the current host name.

   void login(const std::string& hostname, LoginMethod loginMethod, const std::string& username, const std::string& password);
      /// Logs in to the SMTP server using the given authentication method and the given
      /// credentials.

   void login(LoginMethod loginMethod, const std::string& username, const std::string& password);
      /// Logs in to the SMTP server using the given authentication method and the given
      /// credentials.
      
   void open();
      /// Reads the initial response from the SMTP server.
      ///
      /// Usually called implicitly through login(), but can
      /// also be called explicitly to implement different forms
      /// of SMTP authentication.
      ///
      /// Does nothing if called more than once.

   void close();
      /// Sends a QUIT command and closes the connection to the server.   
      ///
      /// Throws a SMTPException in case of a SMTP-specific error, or a
      /// NetException in case of a general network communication failure.

   void sendMessage(const MailMessage& message);
      /// Sends the given mail message by sending a MAIL FROM command,
      /// a RCPT TO command for every recipient, and a DATA command with
      /// the message headers and content.
      ///
      /// Throws a SMTPException in case of a SMTP-specific error, or a
      /// NetException in case of a general network communication failure.

   int sendCommand(const std::string& command, std::string& response);
      /// Sends the given command verbatim to the server
      /// and waits for a response.
      ///
      /// Throws a SMTPException in case of a SMTP-specific error, or a
      /// NetException in case of a general network communication failure.

   int sendCommand(const std::string& command, const std::string& arg, std::string& response);
      /// Sends the given command verbatim to the server
      /// and waits for a response.
      ///
      /// Throws a SMTPException in case of a SMTP-specific error, or a
      /// NetException in case of a general network communication failure.

protected:
   enum StatusClass
   {
      SMTP_POSITIVE_COMPLETION   = 2,
      SMTP_POSITIVE_INTERMEDIATE = 3,
      SMTP_TRANSIENT_NEGATIVE    = 4,
      SMTP_PERMANENT_NEGATIVE    = 5
   };
   enum
   {
      DEFAULT_TIMEOUT = 30000000 // 30 seconds default timeout for socket operations   
   };

   static bool isPositiveCompletion(int status);
   static bool isPositiveIntermediate(int status);
   static bool isTransientNegative(int status);
   static bool isPermanentNegative(int status);

   void login(const std::string& hostname, std::string& response);
   void loginUsingCRAMMD5(const std::string& username, const std::string& password);
   void loginUsingCRAMSHA1(const std::string& username, const std::string& password);
   void loginUsingCRAM(const std::string& username, const std::string& method, Poco::DigestEngine& hmac);
   void loginUsingLogin(const std::string& username, const std::string& password);
   void loginUsingPlain(const std::string& username, const std::string& password);
   DialogSocket& socket();

private:
   DialogSocket _socket;
   bool         _isOpen;
};


//
// inlines
//
inline bool SMTPClientSession::isPositiveCompletion(int status)
{
   return status/100 == SMTP_POSITIVE_COMPLETION;
}


inline bool SMTPClientSession::isPositiveIntermediate(int status)
{
   return status/100 == SMTP_POSITIVE_INTERMEDIATE;
}


inline bool SMTPClientSession::isTransientNegative(int status)
{
   return status/100 == SMTP_TRANSIENT_NEGATIVE;
}


inline bool SMTPClientSession::isPermanentNegative(int status)
{
   return status/100 == SMTP_PERMANENT_NEGATIVE;
}


inline DialogSocket& SMTPClientSession::socket()
{
   return _socket;
}


} } // namespace Poco::Net


#endif // Net_SMTPClientSession_INCLUDED


(the SMTPClientSession class continues on, I just didnt want to paste the whole file)

As you can see, the SMTPClientSession class is properly defined, but the MailMessage class has no content (look around line 10-20, you can see this clearly)! I cannot use a MailMessage object in my code, which effectively prevents me from being able to create my program. Can anyone tell me what I need to do to fix this?
xcdemon05
 
Posts: 2
Joined: 22 Feb 2014, 19:03

Re: Missing definition for MailMessage in SMTPClientSession.

Postby guenter » 22 Feb 2014, 20:36

Code: Select all
#include "Poco/Net/MailMessage.h"

in your code could help.
guenter
 
Posts: 1132
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Missing definition for MailMessage in SMTPClientSession.

Postby cristiantm » 23 Feb 2014, 22:11

A long(er) explanation is that Poco uses a lot of forward declaration. The class is defined in another file (MailMessage.h/cpp), and they only say that it exist where it is needed, since thats enough if you are not going to really use its methods in the file. In the Poco Style Guide you can find a liitle bit more about why it is like that.

The short explanation is: just include the specific headers for every object that you are going to manipulate and it will work as expected :)
cristiantm
 
Posts: 11
Joined: 05 Mar 2013, 13:58


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests