|
|
Comments and Discussions
|
|
 |

|
there are changes that are specific to what I'm using it for. But the original code did not work for me.
the same for the other post I made.
|
|
|
|

|
this will fix the AUTH PLAIN process
also the MD5-DIGEST is broken but you should not used it anymore
else if(IsKeywordSupported(RecvBuf, "PLAIN") == true)
{
pEntry = FindCommandEntry(command_AUTHPLAIN);
unsigned char ustrLogin[200];
ZeroMemory( ustrLogin, 200);
memcpy(ustrLogin, m_sLogin.c_str(), m_sLogin.length());
memcpy(ustrLogin + m_sLogin.length() + 1, m_sLogin.c_str(), m_sLogin.length());
memcpy(ustrLogin + 2 * m_sLogin.length() + 2, m_sPassword.c_str(), m_sPassword.length());
std::string encoded_login = base64_encode(ustrLogin, m_sLogin.length() * 2 + m_sPassword.length() + 2);
pEntry = FindCommandEntry(command_PASSWORD);
sprintf(SendBuf, "AUTH PLAIN %s\r\n", encoded_login.c_str());
SendData(pEntry);
ReceiveResponse(pEntry);
}
|
|
|
|

|
Doesn't this get the exact same result as the current code? Is there some portability issue with how it is currently written?
|
|
|
|

|
I have to check, but the fixes were made testing with the actual email services.
|
|
|
|

|
If there is a exception in SayQuit.RecieveResponse, the outer most exception handler would be called, which would then unwind the CSmtp object. Then the desstructor would be called, but m_bConnected was not set to false(it was setted after RecieveResponse), so the destrutor would call DisconnectRemoteServer...
Finally, the application will crash.
|
|
|
|

|
Thanks for finding and contributing this. Can you propose a solution and we will incorporate it into the next release?
Thanks,
David
|
|
|
|

|
strcpy(SendBuf, "QUIT\r\n");
m_bConnected=false;
SendData(pEntry);
ReceiveResponse(pEntry);
just put m_bConnected = false before SendData() in SayQuit.
|
|
|
|

|
how to add a socket proxy class on it? so that I can set socket4/5 proxy when I send email?
like http://www.codeproject.com/Articles/1652/CAsyncProxySocket-CAsyncSocket-derived-class-to-co
or other socket proxy class. where should i add the code?
|
|
|
|

|
else if(IsKeywordSupported(RecvBuf, "PLAIN") == true)
{
pEntry = FindCommandEntry(command_AUTHPLAIN);
sprintf(SendBuf, "^%s^%s", m_sLogin.c_str(), m_sPassword.c_str());
for(unsigned int i=0; i<strlen(SendBuf); i++)
{
if(SendBuf[i]=='^') SendBuf[i]='\0';
}
const unsigned char *ustrLogin = CharToUnsignedChar(SendBuf);
std::string encoded_login = base64_encode(ustrLogin, strlen(SendBuf));
delete[] ustrLogin;
sprintf(SendBuf, "AUTH PLAIN %s", encoded_login.c_str());
SendData(pEntry);
ReceiveResponse(pEntry);
}
Check, please. You are printing to "^%s^%s", then replace ^ with 0, then use strlen.
Strlen will return 0 in this case all the time.
Am i right about bug?
modified 21 Nov '12 - 8:25.
|
|
|
|

|
You are right. Here are the changes that are necessary to make it work properly:
CSmtp.cpp line 78 needs to be changed to:
{command_AUTHPLAIN, 5*60, 5*60, 235, ECSmtp::COMMAND_AUTH_PLAIN},
CSmtp.cpp starting at line 863 should be changed to:
else if(IsKeywordSupported(RecvBuf, "PLAIN") == true)
{
pEntry = FindCommandEntry(command_AUTHPLAIN);
sprintf(SendBuf, "%s^%s^%s", m_sLogin.c_str(), m_sLogin.c_str(), m_sPassword.c_str());
unsigned int length = strlen(SendBuf);
unsigned char *ustrLogin = CharToUnsignedChar(SendBuf);
for(unsigned int i=0; i<length; i++)
{
if(ustrLogin[i]==94) ustrLogin[i]=0;
}
std::string encoded_login = base64_encode(ustrLogin, length);
delete[] ustrLogin;
sprintf(SendBuf, "AUTH PLAIN %s\r\n", encoded_login.c_str());
SendData(pEntry);
ReceiveResponse(pEntry);
}
I'll post these changes in the next release, but at least for now you can easily change version 2.1 to include this fix.
|
|
|
|

|
Works great on OS X with some minor changes.
Please let me know where to submit them for inclusion.
Nice project, works fine for me.
thanks!
|
|
|
|

|
Davembg,
Great! Thanks for your contribution. Hopefully the changes are over version 2.1, which will make them easy to incorporate. You can zip them and send them to davidandrebecca.johns_at_gmail_dot_com.
|
|
|
|
|

|
It didn't compile out of the box - the TLS setting was scoped as if it was part of the Csmtp class, but it's separate. Once main() was corrected for that, it ran and worked fine.
|
|
|
|

|
Hello my friend, thanks for this AWESOME lib. I have a problem. I wrote this program that loops around and sends a message at a fixed interval. My problem usually occurs when I send a file around 3.5MB. Sometimes after 2-10 iterations, the program hangs within the mail.Send() routine. I dont get any error, just an appcrash. The error occurs irregularly. Any ideas on to what might be causing this?
|
|
|
|

|
I also get an SSL error rarely but it causes the application to crash. Any ideas on how to acknowledge the error but not end the program?
|
|
|
|

|
You could put a try{}catch() around where the error occurs. Have you trapped what line in the code can lead to the crash?
|
|
|
|

|
Hi David, Here's what I tried. There is already a try/catch statement around the mail.send() call. Do I need to add something more? I added more exception definitions to pinpoint exactly which function and line causes the SSL error. I just run it now and I got an error exception from the SendData_SSL function. The thing is that I dont mind if it fails some times, the problem is that the whole program crashes with the exception. Am I doing something wrong? How can I avoid the program crashing completely on any exception? Any ideas?
|
|
|
|

|
Hi David, Im using visual studio c++ 2012 btw. It seems that if I put some fake throw commands in functions the catching works ok. BUT if I add fake throw's in the functions such as readdata_ssl or writedata_ssl (that originally were creating problems) it seems that the exception propagates and re-fires until it reaches my main and then the program crashes with an unhandled exception. It should only propagate once isn't it? since you have one "throw" in the nested catch? Anyways what I did was to add another nested try/catch statement in my main and it seems to work. Shouldn't the exception be cleared or deleted when caught. Weird. Im more of a pure C programmer at heart so please forgive me if I missed anything. Great library anyways!
|
|
|
|

|
The only try{}catch() blocks are catching const ECSmtp&. It must be that another object type is being thrown. You could put a catch(...) after the catch(const ECSmtp&) to catch any other object types that are thrown. This would isolate the issue that is crashing your program. If you find a good solution, please post back with the exact changes you propose.
Thanks,
David
|
|
|
|

|
Has anyone tried testing this with a GMAIL account configured to use 2-factor authentication?
|
|
|
|

|
Very nice code!
Thank you very much!
|
|
|
|

|
Your sample code saved me much time understanding the OpenSSL library.
Thanks a lot !
|
|
|
|

|
Hi All,
Does anyone has the workspace working in VC++ 6.0? If yes please send. Otherwise, please send the source code of openssl used in the project so that i can build in VC++ 6.0 to eliminate linking errors.
It is urgent.
Thanks in advance,
Santosh
With regards
A.Santosh
|
|
|
|

|
yeah i have used this in vc6.0 without any problem.if you are facing any such error then let me know,would try to resolve them.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
C++ SMTP client, support SSL and TLS encrypted connection to SMTP server
| Type | Article |
| Licence | CPOL |
| First Posted | 3 Aug 2010 |
| Views | 226,578 |
| Downloads | 11,907 |
| Bookmarked | 133 times |
|
|