1 //////////////////////////////////////////////////////////////////////
2 // Original class CFastSmtp written by
3 // christopher w. backen <immortal@cox.net>
4 // More details at: http://www.codeproject.com/KB/IP/zsmtp.aspx
7 // 1. name of the class and some functions
8 // 2. new functions added: SendData,ReceiveData and more
9 // 3. authentication added
10 // 4. attachments added
11 // introduced by Jakub Piwowarczyk
12 // More details at: http://www.codeproject.com/KB/mcpp/CSmtp.aspx
13 //////////////////////////////////////////////////////////////////////
18 #pragma warning(disable:4786)
20 //////////////////////////////////////////////////////////////////////
21 // Construction/Destruction
22 //////////////////////////////////////////////////////////////////////
26 // Initialize variables
27 m_oError
= CSMTP_NO_ERROR
;
28 m_iXPriority
= XPRIORITY_NORMAL
;
31 m_pcLocalHostName
= NULL
;
41 m_pcSMTPSrvName
= NULL
;
43 if((RecvBuf
= new char[BUFFER_SIZE
]) == NULL
)
45 m_oError
= CSMTP_LACK_OF_MEMORY
;
49 if((SendBuf
= new char[BUFFER_SIZE
]) == NULL
)
51 m_oError
= CSMTP_LACK_OF_MEMORY
;
56 WORD wVer
= MAKEWORD(2,2);
57 if (WSAStartup(wVer
,&wsaData
) != NO_ERROR
)
59 m_oError
= CSMTP_WSA_STARTUP
;
62 if (LOBYTE( wsaData
.wVersion
) != 2 || HIBYTE( wsaData
.wVersion
) != 2 )
64 m_oError
= CSMTP_WSA_VER
;
75 BCCRecipients
.clear();
79 if (m_pcLocalHostName
)
80 delete[] m_pcLocalHostName
;
82 delete[] m_pcMailFrom
;
84 delete[] m_pcNameFrom
;
96 delete[] m_pcPassword
;
106 //////////////////////////////////////////////////////////////////////
108 //////////////////////////////////////////////////////////////////////
110 bool CSmtp::AddAttachment(const char *path
)
112 std::string
str(path
);
113 Attachments
.insert(Attachments
.end(),str
);
117 bool CSmtp::AddRecipient(const char *email
, const char *name
)
123 m_oError
= CSMTP_UNDEF_RECIPENT_MAIL
;
128 recipent
.Mail
.insert(0,email
);
129 name
!=NULL
? recipent
.Name
.insert(0,name
) : recipent
.Name
.insert(0,"");
131 Recipients
.insert(Recipients
.end(), recipent
);
136 bool CSmtp::AddCCRecipient(const char *email
, const char *name
)
142 m_oError
= CSMTP_UNDEF_RECIPENT_MAIL
;
147 recipent
.Mail
.insert(0,email
);
148 name
!=NULL
? recipent
.Name
.insert(0,name
) : recipent
.Name
.insert(0,"");
150 CCRecipients
.insert(CCRecipients
.end(), recipent
);
155 bool CSmtp::AddBCCRecipient(const char *email
, const char *name
)
161 m_oError
= CSMTP_UNDEF_RECIPENT_MAIL
;
166 recipent
.Mail
.insert(0,email
);
167 name
!=NULL
? recipent
.Name
.insert(0,name
) : recipent
.Name
.insert(0,"");
169 BCCRecipients
.insert(BCCRecipients
.end(), recipent
);
176 unsigned int i
,rcpt_count
,res
,FileId
;
177 char *FileBuf
= NULL
, *FileName
= NULL
;
179 unsigned long int FileSize
,TotalSize
,MsgPart
;
181 // ***** CONNECTING TO SMTP SERVER *****
183 assert(m_pcSMTPSrvName
);
185 // connecting to remote host:
186 if( (hSocket
= ConnectRemoteServer(m_pcSMTPSrvName
, m_iSMTPSrvPort
)) == INVALID_SOCKET
)
188 m_oError
= CSMTP_WSA_INVALID_SOCKET
;
195 switch(SmtpXYZdigits())
200 m_oError
= CSMTP_SERVER_NOT_READY
;
204 // EHLO <SP> <domain> <CRLF>
205 sprintf(SendBuf
,"EHLO %s\r\n",GetLocalHostName()!=NULL
? m_pcLocalHostName
: "domain");
212 switch(SmtpXYZdigits())
217 m_oError
= CSMTP_COMMAND_EHLO
;
221 // AUTH <SP> LOGIN <CRLF>
222 strcpy(SendBuf
,"AUTH LOGIN\r\n");
229 switch(SmtpXYZdigits())
234 m_oError
= CSMTP_COMMAND_AUTH_LOGIN
;
241 m_oError
= CSMTP_UNDEF_LOGIN
;
244 std::string encoded_login
= base64_encode(reinterpret_cast<const unsigned char*>(m_pcLogin
), (unsigned int)strlen(m_pcLogin
));
245 sprintf(SendBuf
,"%s\r\n",encoded_login
.c_str());
252 switch(SmtpXYZdigits())
257 m_oError
= CSMTP_UNDEF_XYZ_RESPOMSE
;
264 m_oError
= CSMTP_UNDEF_PASSWORD
;
267 std::string encoded_password
= base64_encode(reinterpret_cast<const unsigned char*>(m_pcPassword
), (unsigned int)strlen(m_pcPassword
));
268 sprintf(SendBuf
,"%s\r\n",encoded_password
.c_str());
275 switch(SmtpXYZdigits())
280 m_oError
= CSMTP_BAD_LOGIN_PASS
;
283 m_oError
= CSMTP_UNDEF_XYZ_RESPOMSE
;
287 // ***** SENDING E-MAIL *****
289 // MAIL <SP> FROM:<reverse-path> <CRLF>
290 if(m_pcMailFrom
== NULL
)
292 m_oError
= CSMTP_UNDEF_MAILFROM
;
295 sprintf(SendBuf
,"MAIL FROM:<%s>\r\n",m_pcMailFrom
);
302 switch(SmtpXYZdigits())
307 m_oError
= CSMTP_COMMAND_MAIL_FROM
;
311 // RCPT <SP> TO:<forward-path> <CRLF>
312 rcpt_count
= (unsigned int)Recipients
.size();
313 for(i
=0;i
<Recipients
.size();i
++)
315 sprintf(SendBuf
,"RCPT TO:<%s>\r\n",(Recipients
.at(i
).Mail
).c_str());
322 switch(SmtpXYZdigits())
327 m_oError
= CSMTP_COMMAND_RCPT_TO
;
333 for(i
=0;i
<CCRecipients
.size();i
++)
335 sprintf(SendBuf
,"RCPT TO:<%s>\r\n",(CCRecipients
.at(i
).Mail
).c_str());
342 for(i
=0;i
<BCCRecipients
.size();i
++)
344 sprintf(SendBuf
,"RCPT TO:<%s>\r\n",(BCCRecipients
.at(i
).Mail
).c_str());
353 strcpy(SendBuf
,"DATA\r\n");
360 switch(SmtpXYZdigits())
365 m_oError
= CSMTP_COMMAND_DATA
;
370 if(!FormatHeader(SendBuf
))
372 m_oError
= CSMTP_UNDEF_MSG_HEADER
;
379 sprintf(SendBuf
,"%s\r\n",m_pcMsgBody
); // NOTICE: each line ends with <CRLF>
383 // next goes attachments (if they are)
384 if((FileBuf
= new char[55]) == NULL
)
386 m_oError
= CSMTP_LACK_OF_MEMORY
;
389 if((FileName
= new char[255]) == NULL
)
391 m_oError
= CSMTP_LACK_OF_MEMORY
;
396 for(FileId
=0;FileId
<Attachments
.size();FileId
++)
398 strcpy(FileName
,Attachments
[FileId
].c_str());
400 sprintf(SendBuf
,"--%s\r\n",BOUNDARY_TEXT
);
401 strcat(SendBuf
,"Content-Type: application/x-msdownload; name=\"");
402 strcat(SendBuf
,&FileName
[Attachments
[FileId
].find_last_of("\\") + 1]);
403 strcat(SendBuf
,"\"\r\n");
404 strcat(SendBuf
,"Content-Transfer-Encoding: base64\r\n");
405 strcat(SendBuf
,"Content-Disposition: attachment; filename=\"");
406 strcat(SendBuf
,&FileName
[Attachments
[FileId
].find_last_of("\\") + 1]);
407 strcat(SendBuf
,"\"\r\n");
408 strcat(SendBuf
,"\r\n");
418 hFile
= fopen(FileName
,"rb");
421 m_oError
= CSMTP_FILE_NOT_EXIST
;
425 // checking file size:
428 FileSize
+= (unsigned long)fread(FileBuf
,sizeof(char),54,hFile
);
429 TotalSize
+= FileSize
;
432 if(TotalSize
/1024 > MSG_SIZE_IN_MB
*1024)
433 m_oError
= CSMTP_MSG_TOO_BIG
;
436 fseek (hFile
,0,SEEK_SET
);
439 for(i
=0;i
<FileSize
/54+1;i
++)
441 res
= (unsigned int)fread(FileBuf
,sizeof(char),54,hFile
);
442 MsgPart
? strcat(SendBuf
,base64_encode(reinterpret_cast<const unsigned char*>(FileBuf
),res
).c_str())
443 : strcpy(SendBuf
,base64_encode(reinterpret_cast<const unsigned char*>(FileBuf
),res
).c_str());
444 strcat(SendBuf
,"\r\n");
446 if(MsgPart
>= BUFFER_SIZE
/2)
447 { // sending part of the message
474 // sending last message block (if there is one or more attachments)
475 if (!Attachments
.empty())
477 sprintf(SendBuf
,"\r\n--%s--\r\n",BOUNDARY_TEXT
);
483 strcpy(SendBuf
,"\r\n.\r\n");
490 switch(SmtpXYZdigits())
495 m_oError
= CSMTP_MSG_BODY_ERROR
;
499 // ***** CLOSING CONNECTION *****
502 strcpy(SendBuf
,"QUIT\r\n");
509 switch(SmtpXYZdigits())
514 m_oError
= CSMTP_COMMAND_QUIT
;
519 closesocket(hSocket
);
524 SOCKET
CSmtp::ConnectRemoteServer(const char *server
,const unsigned short port
)
529 SOCKADDR_IN sockAddr
;
530 SOCKET hServerSocket
= INVALID_SOCKET
;
533 // If the user input is an alpha name for the host, use gethostbyname()
534 // If not, get host by addr (assume IPv4)
535 if(isalpha(server
[0]))
536 lpHostEnt
= gethostbyname(server
);
539 addr
.s_addr
= inet_addr(server
);
540 if(addr
.s_addr
== INADDR_NONE
)
542 m_oError
= CSMTP_BAD_IPV4_ADDR
;
543 return INVALID_SOCKET
;
546 lpHostEnt
= gethostbyaddr((char *) &addr
, 4, AF_INET
);
549 if(lpHostEnt
!= NULL
)
551 if((hServerSocket
= socket(PF_INET
, SOCK_STREAM
,0)) != INVALID_SOCKET
)
554 nProtocolPort
= htons(port
);
557 lpServEnt
= getservbyname("mail", 0);
558 if (lpServEnt
== NULL
)
559 nProtocolPort
= htons(25);
561 nProtocolPort
= lpServEnt
->s_port
;
564 sockAddr
.sin_family
= AF_INET
;
565 sockAddr
.sin_port
= nProtocolPort
;
566 sockAddr
.sin_addr
= *((LPIN_ADDR
)*lpHostEnt
->h_addr_list
);
567 if(connect(hServerSocket
,(PSOCKADDR
)&sockAddr
,sizeof(sockAddr
)) == SOCKET_ERROR
)
569 m_oError
= CSMTP_WSA_CONNECT
;
570 hServerSocket
= INVALID_SOCKET
;
575 m_oError
= CSMTP_WSA_INVALID_SOCKET
;
576 return INVALID_SOCKET
;
581 m_oError
= CSMTP_WSA_GETHOSTBY_NAME_ADDR
;
582 return INVALID_SOCKET
;
585 return hServerSocket
;
588 int CSmtp::SmtpXYZdigits()
593 return (RecvBuf
[0]-'0')*100 + (RecvBuf
[1]-'0')*10 + RecvBuf
[2]-'0';
596 bool CSmtp::FormatHeader(char* header
)
598 unsigned int i
,s
= 0;
605 // check for at least one recipient
606 if (!Recipients
.empty())
608 for (i
=s
=0;i
<Recipients
.size();i
++)
609 s
+= (unsigned int)(Recipients
[i
].Mail
.size() + Recipients
[i
].Name
.size() + 3);
612 if((to
= new char[s
]) == NULL
)
614 m_oError
= CSMTP_LACK_OF_MEMORY
;
619 for (i
=0;i
<Recipients
.size();i
++)
621 i
> 0 ? strcat(to
,","):strcpy(to
,"");
622 strcat(to
,Recipients
[i
].Name
.c_str());
624 strcat(to
,Recipients
[i
].Mail
.c_str());
630 m_oError
= CSMTP_UNDEF_RECIPENTS
;
634 if (!CCRecipients
.empty())
636 for (i
=s
=0;i
<CCRecipients
.size();i
++)
637 s
+= (unsigned int)(CCRecipients
[i
].Mail
.size() + CCRecipients
[i
].Name
.size() + 3);
640 if((cc
= new char[s
]) == NULL
)
642 m_oError
= CSMTP_LACK_OF_MEMORY
;
648 for (i
=0;i
<CCRecipients
.size();i
++)
650 i
> 0 ? strcat(cc
,","):strcpy(cc
,"");
651 strcat(cc
,CCRecipients
[i
].Name
.c_str());
653 strcat(cc
,CCRecipients
[i
].Mail
.c_str());
658 if (!BCCRecipients
.empty())
660 for (i
=s
=0;i
<BCCRecipients
.size();i
++)
661 s
+= (unsigned int)(BCCRecipients
[i
].Mail
.size() + BCCRecipients
[i
].Name
.size() + 3);
664 if((bcc
= new char[s
]) == NULL
)
666 m_oError
= CSMTP_LACK_OF_MEMORY
;
673 for (i
=0;i
<BCCRecipients
.size();i
++)
675 i
> 0 ? strcat(bcc
,","):strcpy(bcc
,"");
676 strcat(bcc
,BCCRecipients
[i
].Name
.c_str());
678 strcat(bcc
,BCCRecipients
[i
].Mail
.c_str());
683 // Date: <SP> <dd> <SP> <mon> <SP> <yy> <SP> <hh> ":" <mm> ":" <ss> <SP> <zone> <CRLF>
685 ::GetSystemTime(&st
);
686 ::GetDateFormatA(MAKELCID(0x0409,SORT_DEFAULT
),0,&st
,"ddd\',\' dd MMM yyyy",szDate
,sizeof(szDate
));
687 ::GetTimeFormatA(MAKELCID(0x0409,SORT_DEFAULT
),TIME_FORCE24HOURFORMAT
,&st
,"HH\':\'mm\':\'ss",sztTime
,sizeof(sztTime
));
688 sprintf(header
,"Date: %s %s\r\n", szDate
, sztTime
);
690 // From: <SP> <sender> <SP> "<" <sender-email> ">" <CRLF>
691 if(m_pcMailFrom
== NULL
)
693 m_oError
= CSMTP_UNDEF_MAILFROM
;
699 strcat(header
,"From: ");
701 strcat(header
, m_pcNameFrom
);
703 strcat(header
,m_pcMailFrom
);
704 strcat(header
, ">\r\n");
706 // X-Mailer: <SP> <xmailer-app> <CRLF>
707 if (m_pcXMailer
!= NULL
)
709 strcat(header
,"X-Mailer: ");
710 strcat(header
, m_pcXMailer
);
711 strcat(header
, "\r\n");
714 // Reply-To: <SP> <reverse-path> <CRLF>
715 if(m_pcReplyTo
!= NULL
)
717 strcat(header
, "Reply-To: ");
718 strcat(header
, m_pcReplyTo
);
719 strcat(header
, "\r\n");
722 // X-Priority: <SP> <number> <CRLF>
726 strcat(header
,"X-Priority: 2 (High)\r\n");
728 case XPRIORITY_NORMAL
:
729 strcat(header
,"X-Priority: 3 (Normal)\r\n");
732 strcat(header
,"X-Priority: 4 (Low)\r\n");
735 strcat(header
,"X-Priority: 3 (Normal)\r\n");
738 // To: <SP> <remote-user-mail> <CRLF>
739 strcat(header
,"To: ");
741 strcat(header
, "\r\n");
743 // Cc: <SP> <remote-user-mail> <CRLF>
744 if (!CCRecipients
.empty())
746 strcat(header
,"Cc: ");
748 strcat(header
, "\r\n");
751 if (!BCCRecipients
.empty())
753 strcat(header
,"Bcc: ");
755 strcat(header
, "\r\n");
758 // Subject: <SP> <subject-text> <CRLF>
759 if(m_pcSubject
== NULL
)
761 m_oError
= CSMTP_UNDEF_SUBJECT
;
762 strcat(header
, "Subject: ");
766 strcat(header
, "Subject: ");
767 strcat(header
, m_pcSubject
);
769 strcat(header
, "\r\n");
771 // MIME-Version: <SP> 1.0 <CRLF>
772 strcat(header
,"MIME-Version: 1.0\r\n");
773 if(!Attachments
.size())
775 strcat(header
,"Content-type: text/plain; charset=US-ASCII\r\n");
776 strcat(header
,"Content-Transfer-Encoding: 7bit\r\n");
777 strcat(SendBuf
,"\r\n");
780 { // there is one or more attachments
781 strcat(header
,"Content-Type: multipart/mixed; boundary=\"");
782 strcat(header
,BOUNDARY_TEXT
);
783 strcat(header
,"\"\r\n");
784 strcat(header
,"\r\n");
785 // first goes text message
786 strcat(SendBuf
,"--");
787 strcat(SendBuf
,BOUNDARY_TEXT
);
788 strcat(SendBuf
,"\r\n");
789 strcat(SendBuf
,"Content-type: text/plain; charset=US-ASCII\r\n");
790 strcat(SendBuf
,"Content-Transfer-Encoding: 7bit\r\n");
791 strcat(SendBuf
,"\r\n");
803 bool CSmtp::ReceiveData()
812 if( (res
= recv(hSocket
,RecvBuf
,BUFFER_SIZE
,0)) == SOCKET_ERROR
)
814 m_oError
= CSMTP_WSA_RECV
;
819 m_oError
= CSMTP_CONNECTION_CLOSED
;
827 bool CSmtp::SendData()
831 int idx
= 0,res
,nLeft
= (int)strlen(SendBuf
);
834 if ((res
= send(hSocket
, &SendBuf
[idx
], nLeft
, 0)) == SOCKET_ERROR
)
836 m_oError
= CSMTP_WSA_SEND
;
847 CSmtpError
CSmtp::GetLastError()
853 const char* const CSmtp::GetLocalHostIP()
855 in_addr *iaHost = NULL;
861 if(gethostname(m_pcHostName,255) != SOCKET_ERROR)
863 pHe = gethostbyname(m_pcHostName);
866 for (int i=0;pHe->h_addr_list[i] != 0;i++)
868 iaHost = (LPIN_ADDR)pHe->h_addr_list[i];
869 m_pcIPAddr = inet_ntoa(*iaHost);
875 m_oError = CSMTP_WSA_GETHOSTBY_NAME_ADDR;
883 const char* const CSmtp::GetLocalHostName()
885 if(m_pcLocalHostName
)
886 delete[] m_pcLocalHostName
;
887 if((m_pcLocalHostName
= new char[255]) == NULL
)
889 m_oError
= CSMTP_LACK_OF_MEMORY
;
892 if(gethostname((char FAR
*)m_pcLocalHostName
,255) == SOCKET_ERROR
)
893 m_oError
= CSMTP_WSA_HOSTNAME
;
894 return m_pcLocalHostName
;
897 unsigned const int CSmtp::GetBCCRecipientCount()
899 return (unsigned int)BCCRecipients
.size();
902 unsigned const int CSmtp::GetCCRecipientCount()
904 return (unsigned int)CCRecipients
.size();
907 const char* const CSmtp::GetMessageBody()
912 unsigned const int CSmtp::GetRecipientCount()
914 return (unsigned int)Recipients
.size();
917 const char* const CSmtp::GetReplyTo()
922 const char* const CSmtp::GetMailFrom()
927 const char* const CSmtp::GetSenderName()
932 const char* const CSmtp::GetSubject()
937 const char* const CSmtp::GetXMailer()
942 CSmptXPriority
CSmtp::GetXPriority()
947 void CSmtp::SetXPriority(CSmptXPriority priority
)
949 m_iXPriority
= priority
;
952 void CSmtp::SetMessageBody(const char *body
)
955 int s
= (int)strlen(body
);
957 delete[] m_pcMsgBody
;
958 if((m_pcMsgBody
= new char[s
+1]) == NULL
)
960 m_oError
= CSMTP_LACK_OF_MEMORY
;
963 strcpy(m_pcMsgBody
, body
);
966 void CSmtp::SetReplyTo(const char *replyto
)
969 int s
= (int)strlen(replyto
);
971 delete[] m_pcReplyTo
;
972 if((m_pcReplyTo
= new char[s
+1]) == NULL
)
974 m_oError
= CSMTP_LACK_OF_MEMORY
;
977 strcpy(m_pcReplyTo
, replyto
);
980 void CSmtp::SetSenderMail(const char *email
)
983 int s
= (int)strlen(email
);
985 delete[] m_pcMailFrom
;
986 if((m_pcMailFrom
= new char[s
+1]) == NULL
)
988 m_oError
= CSMTP_LACK_OF_MEMORY
;
991 strcpy(m_pcMailFrom
, email
);
994 void CSmtp::SetSenderName(const char *name
)
997 int s
= (int)strlen(name
);
999 delete[] m_pcNameFrom
;
1000 if((m_pcNameFrom
= new char[s
+1]) == NULL
)
1002 m_oError
= CSMTP_LACK_OF_MEMORY
;
1005 strcpy(m_pcNameFrom
, name
);
1008 void CSmtp::SetSubject(const char *subject
)
1011 int s
= (int)strlen(subject
);
1013 delete[] m_pcSubject
;
1014 m_pcSubject
= new char[s
+1];
1015 strcpy(m_pcSubject
, subject
);
1018 void CSmtp::SetXMailer(const char *xmailer
)
1021 int s
= (int)strlen(xmailer
);
1023 delete[] m_pcXMailer
;
1024 if((m_pcXMailer
= new char[s
+1]) == NULL
)
1026 m_oError
= CSMTP_LACK_OF_MEMORY
;
1029 strcpy(m_pcXMailer
, xmailer
);
1032 void CSmtp::SetLogin(const char *login
)
1035 int s
= (int)strlen(login
);
1038 if((m_pcLogin
= new char[s
+1]) == NULL
)
1040 m_oError
= CSMTP_LACK_OF_MEMORY
;
1043 strcpy(m_pcLogin
, login
);
1046 void CSmtp::SetPassword(const char *password
)
1049 int s
= (int)strlen(password
);
1051 delete[] m_pcPassword
;
1052 if((m_pcPassword
= new char[s
+1]) == NULL
)
1054 m_oError
= CSMTP_LACK_OF_MEMORY
;
1057 strcpy(m_pcPassword
, password
);
1060 void CSmtp::SetSMTPServer(const char* SrvName
,const unsigned short SrvPort
)
1063 m_iSMTPSrvPort
= SrvPort
;
1064 int s
= (int)strlen(SrvName
);
1066 delete[] m_pcSMTPSrvName
;
1067 if((m_pcSMTPSrvName
= new char[s
+1]) == NULL
)
1069 m_oError
= CSMTP_LACK_OF_MEMORY
;
1072 strcpy(m_pcSMTPSrvName
, SrvName
);
1075 //////////////////////////////////////////////////////////////////////
1077 //////////////////////////////////////////////////////////////////////
1079 char* GetErrorText(CSmtpError ErrorId
)
1083 case CSMTP_NO_ERROR
:
1085 case CSMTP_WSA_STARTUP
:
1086 return "Unable to initialise winsock2.";
1088 return "Wrong version of the winsock2.";
1089 case CSMTP_WSA_SEND
:
1090 return "Function send() failed.";
1091 case CSMTP_WSA_RECV
:
1092 return "Function recv() failed.";
1093 case CSMTP_WSA_CONNECT
:
1094 return "Function connect failed.";
1095 case CSMTP_WSA_GETHOSTBY_NAME_ADDR
:
1096 return "Functions gethostbyname() or gethostbyaddr() failed.";
1097 case CSMTP_WSA_INVALID_SOCKET
:
1098 return "Invalid winsock2 socket.";
1099 case CSMTP_WSA_HOSTNAME
:
1100 return "Function hostname() failed.";
1101 case CSMTP_BAD_IPV4_ADDR
:
1102 return "Improper IPv4 address.";
1103 case CSMTP_UNDEF_MSG_HEADER
:
1104 return "Undefined message header.";
1105 case CSMTP_UNDEF_MAILFROM
:
1106 return "Undefined from is the mail.";
1107 case CSMTP_UNDEF_SUBJECT
:
1108 return "Undefined message subject.";
1109 case CSMTP_UNDEF_RECIPENTS
:
1110 return "Undefined at least one reciepent.";
1111 case CSMTP_UNDEF_RECIPENT_MAIL
:
1112 return "Undefined recipent mail.";
1113 case CSMTP_UNDEF_LOGIN
:
1114 return "Undefined user login.";
1115 case CSMTP_UNDEF_PASSWORD
:
1116 return "Undefined user password.";
1117 case CSMTP_COMMAND_MAIL_FROM
:
1118 return "Server returned error after sending MAIL FROM.";
1119 case CSMTP_COMMAND_EHLO
:
1120 return "Server returned error after sending EHLO.";
1121 case CSMTP_COMMAND_AUTH_LOGIN
:
1122 return "Server returned error after sending AUTH LOGIN.";
1123 case CSMTP_COMMAND_DATA
:
1124 return "Server returned error after sending DATA.";
1125 case CSMTP_COMMAND_QUIT
:
1126 return "Server returned error after sending QUIT.";
1127 case CSMTP_COMMAND_RCPT_TO
:
1128 return "Server returned error after sending RCPT TO.";
1129 case CSMTP_MSG_BODY_ERROR
:
1130 return "Error in message body";
1131 case CSMTP_CONNECTION_CLOSED
:
1132 return "Server has closed the connection.";
1133 case CSMTP_SERVER_NOT_READY
:
1134 return "Server is not ready.";
1135 case CSMTP_FILE_NOT_EXIST
:
1136 return "File not exist.";
1137 case CSMTP_MSG_TOO_BIG
:
1138 return "Message is too big.";
1139 case CSMTP_BAD_LOGIN_PASS
:
1140 return "Bad login or password.";
1141 case CSMTP_UNDEF_XYZ_RESPOMSE
:
1142 return "Undefined xyz SMTP response.";
1143 case CSMTP_LACK_OF_MEMORY
:
1144 return "Lack of memory.";
1146 return "Undefined error id.";
1150 #pragma warning(pop)