On the Internet, Email is the most popular transmission media. This article includes two Protocols:. POP 3 Protocol: POP3 protocol (postal transfer protocol), which means receiving mails from the Email server. I have submitted a class that encapsulates the POP3 protocol. For official descriptions of this agreement, refer to RFC1225. SMTP protocol: SMTP (Simple Mail Transfer Protocol) refers to the mail sent to its destination. For details about the SMTP protocol, refer to RCF 821. My new contribution is to encapsulate the SMTP protocol. I cannot fully implement the SMTP protocol, but you can use it to send emails in many applications. This class has several methods. The method name is the same as the SMTP command, so it is easy to understand. In this class, I once again used CSocket as a class member, so I can use it in the thread. below is the class encoding and comment:
//////////////////////////////////////// //////////////////////////////
// SMTP. h: interface for the CSMTP class.
//
//////////////////////////////////////// //////////////////////////////
# If! Defined (afx_smtp_h1_617f7e82_7f4d_11d1_88a0_1_1c3025811_encoded _)
# Define afx_smtp_h1_617f7e82_7f4d_11d1_88a0_1_1c3025811_encoded _
# If _ MSC_VER> = 1000
# Pragma once
# Endif // _ MSC_VER >=1000
# Define CONNECTION_CHECK 0
# Define HELLO_CHECK 1
# Define MAIL_CHECK 2
# Define RCPT_CHECK 3
# Define DATA_START_CHECK 4
# Define DATA_END_CHECK 5
# Define QUIT_CHECK 6
# Define DATA_CHECK 7
Class CSMTP
{
Public:
BOOL Mail ();//
CString GetErrorMessage ();
BOOL Data (CString Subject, CString Body );
CString GetTo ();
BOOL SetTo (CString );
CString GetFrom ();
Void SetFrom (CString from );
BOOL Mail (CString from );
BOOL Disconnect ();
CString GetHost ();
Void SetHost (CString Host );
BOOL Connect (CString Host, CString Me );
BOOL Connect ();
CSMTP ();
Virtual ~ CSMTP ();
Private:
CString GetError (CString Response );
CString m_ErrorMessage;
BOOL CheckResponse (int Type );
Int m_NoOfTo;
CStringArray m_To;
CString m_From;
CSocket m_SMTPServer;
CString m_Host;
};
# Endif //! Defined (afx_smtp_h1_617f7e82_7f4d_11d1_88a0_1_1c3025811_encoded _)
//////////////////////////////////////// //////////////////////////////////
// SMTP. cpp: implementation of the CSMTP class.
//
//////////////////////////////////////// //////////////////////////////
# Include "stdafx. h"
# Include "MailSend. h"
# Include "SMTP. h"
# Ifdef _ DEBUG
# Undef THIS_FILE
Static char THIS_FILE [] =__ FILE __;
# Define new DEBUG_NEW
# Endif