Files
Work/smtp/SMTP.HPP
2024-08-07 09:16:27 -04:00

80 lines
2.0 KiB
C++

#ifndef _SMTP_SMTPCLIENT_HPP_
#define _SMTP_SMTPCLIENT_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _SOCKET_SOCKET_HPP_
#include <socket/socket.hpp>
#endif
#ifndef _COMMON_BLOCK_HPP_
#include <common/block.hpp>
#endif
#ifndef _COMMON_CONSOLE_HPP_
#include <common/console.hpp>
#endif
#ifndef _SMTP_SMTPRESPONSE_HPP_
#include <smtp/response.hpp>
#endif
class String;
class SMTPClient
{
public:
SMTPClient(void);
virtual ~SMTPClient();
BOOL open(const String &hostName);
void close(void);
BOOL helo(const String &domainName);
BOOL mail(const String &reversePath);
BOOL rcpt(const String &forwardPath);
BOOL data(const Block<String> &mailData);
BOOL verify(const String &forwardPath);
BOOL expand(const String &mailList);
BOOL send(const String &reversePath);
BOOL sendOrMail(const String &reversePath);
BOOL sendAndMail(const String &reversePath);
BOOL help(const String &commandName=String());
BOOL noop(void);
BOOL reset(void);
BOOL turn(void);
BOOL quit(void);
BOOL isConnected(void)const;
protected:
virtual void message(const String &messageString);
virtual void message(Block<String> &messageStrings);
private:
enum {SMTPPort=25};
enum SMTPCmds{Helo,Quit,Mail,From,Recipient,To,Data,Verify,Expand,Send,SendOrMail,SendAndMail,Turn,Reset,Help,Noop};
SMTPClient(const SMTPClient &someSMTPClient);
SMTPClient &operator=(const SMTPClient &someSMTPClient);
WORD putControlData(const String &stringData,WORD waitForResponse=TRUE);
BOOL isInResponse(const String &responseString,SMTPResponse::RspType responseType);
WORD getControlData(void);
void createCmds(void);
SMTPResponse mSMTPResponse;
Socket mSMTPControl;
WSASystem mWSASystem;
Block<String> mSMTPCmds;
String mSpace;
};
inline
BOOL SMTPClient::isInResponse(const String &responseString,SMTPResponse::RspType responseType)
{
return mSMTPResponse.isInResponse(responseString,responseType);
}
inline
BOOL SMTPClient::isConnected(void)const
{
return mSMTPControl.isConnected();
}
inline
void SMTPClient::close(void)
{
mSMTPControl.destroy();
}
#endif