|
Hi!
To upgrade the project to the 64-bit version of Win, first download https:
Secondly, replace the SSL libraries from Project Properties, Linker, General, Additional Library Directories including C:\Program Files\OpenSSL\include and C:\Program Files\OpenSSL\lib. Replace libeay32.dll and ssleay32.dll with libcrypto-3-x64.dll and libssl-3-x64.dll in Project Properties, Linker, Input Property, Additional Dependencies. Place C:\Program Files\OpenSSL\include to C/C++ General Properties Additional Include Directories.
Thanks to the authors of the project
|
|
|
|
|
I had the problem, that connections to mail servers failed after START_TLS because TLSv1.1 is not supported by the mail provider anymore.
I compiled the project with OpenSSL 3.0.5 today an everything is perfect now. Wireshark reports TLSv1.3.
My old SSL version was 0.9.8g64.
|
|
|
|
|
Dear Friend!
Please send to me this Project!
Thank you!
|
|
|
|
|
Good afternoon, the class works perfectly for me and I am very happy with it, but I have a problem with the special unicode characters, for example: KOVAČIČ.
I can only get it to send me KOVACIC.
Is there any way to make the CSmtp::SendData class able to send unicode text like Č?
|
|
|
|
|
Example
...
mail.SetSubject(u8"KOVAČIČ");
...
m_sCharSet = "utf-8";
....
|
|
|
|
|
Hi,
I tried to compil your project CodeProject-SMTPClientWithSSLorTLS with VS2017 and it's ok but when i launch the csmtp.exe i have this error
CSmtp.exe - Erreur système
---------------------------
Impossible d’exécuter le code, car SSLEAY32.dll est introuvable. La réinstallation du programme peut corriger ce problème.
Translation: The code could not be executed because SSLEAY32.dll was not found. Reinstalling the program may correct this problem.
---------------------------
OK
---------------------------
thanks for your help
|
|
|
|
|
|
yes and I use this project
https://www.acclaimsoftware.com/download/CodeProject-SMTPClientWithSSLorTLS.zip
but i don't understand what i should do to correct the error message
modified 27-Jan-22 11:42am.
|
|
|
|
|
How about reaching out to Eric? In the post below yours
|
|
|
|
|
but how should I do to contact him directly in his profile?
|
|
|
|
|
Just reply to his message below
|
|
|
|
|
|
Have you tried downloading SSLEAY32.dll by searching for "Download SSLEAY32.dll". I think that generally this project is becoming more and more out of date. I think that cURL is kept up to date and has better promise. See libcurl example - smtp-tls.c[^]
|
|
|
|
|
ok thanks Eric
I'm going to try ...
|
|
|
|
|
|
Hi,
I tried to compil your project CodeProject-SMTPClientWithSSLorTLS with VS2017 and it's ok but when i launch the csmtp.exe i have this error
CSmtp.exe - Erreur système
---------------------------
Impossible d’exécuter le code, car SSLEAY32.dll est introuvable. La réinstallation du programme peut corriger ce problème.
Translation: The code could not be executed because SSLEAY32.dll was not found. Reinstalling the program may correct this problem.
---------------------------
OK
---------------------------
What can I do ?
thanks for your help
|
|
|
|
|
Hi David and John,
Could someone let me know how to submit the whole project. I made changes to:-
1. Make it work for 64 bit Windows and 32 bit Windows
2. Upgraded it to use openssl-1.0.2u (released in Dec 2019) instead of openssl-0.9.8l (released in Jan 2016)
I didn't want to upgrade the SLL library to the latest because it means having to use extra support DLLs. I personally prefer having it self contained.
There haven't been any updates for five years and I really need to submit the whole project but don't know how to do that. Could you let me know how to do that.
Thanks
Eric
|
|
|
|
|
I found that emails without the correct date/time format or time-zone were blocked by Spam Filters.
To fix it (for Windows), add the following declaration in void CSmtp::FormatHeader(char* header) in CSmtp.cpp:-
char dayofweek[][4] = {"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
TIME_ZONE_INFORMATION TimeZoneInformation;
int success, timezonebias, houroffset, minuteoffset;
Then replace:-
snprintf(header, BUFFER_SIZE, "Date: %d %s %d %d:%d:%d\r\n", timeinfo->tm_mday,
month[timeinfo->tm_mon], timeinfo->tm_year+1900, timeinfo->tm_hour,
timeinfo->tm_min, timeinfo->tm_sec);
With:-
success = GetTimeZoneInformation(&TimeZoneInformation);
timezonebias = TimeZoneInformation.Bias;
if(timeinfo->tm_isdst) timezonebias += TimeZoneInformation.DaylightBias;
timezonebias = -timezonebias;
houroffset = timezonebias / 60;
minuteoffset = timezonebias % 60;
if(minuteoffset < 0) minuteoffset = -minuteoffset;
snprintf(header, BUFFER_SIZE, "Date: %s, %02d %s %04d %02d:%02d:%02d %+02d%02d\r\n", dayofweek[timeinfo->tm_wday], timeinfo->tm_mday,
month[timeinfo->tm_mon], timeinfo->tm_year+1900, timeinfo->tm_hour,
timeinfo->tm_min, timeinfo->tm_sec, houroffset, minuteoffset);
|
|
|
|
|
I found that emails sent with attachments were blocked by Spam Filters if the attachment didn't have the correct mime type.
In this regard PDF attachements need to have the correct PDF mime type "Content-Type: application/pdf".
Only .exe and .dll attachments should have the mime type "Content-Type: application/x-msdownload".
In CSmtp.cpp, search for:-
strcat(SendBuf, "Content-Type: application/x-msdownload; name=\"");
strcat(SendBuf, EncodedFileName.c_str());
strcat(SendBuf, "\"\r\n");
And replace it with:-
// Use the correct mime-type
// see http://www.w3big.com/http/http-content-type.html
const char *LastFourCharsOfFileName = FileName.c_str() + strlen(FileName.c_str()) - 4;
if(strlen(FileName.c_str()) < 4)
{
// Very short filename which can't have a three letter extension, so do nothing
}
else if(!_stricmp(LastFourCharsOfFileName, ".pdf"))
{
strcat(SendBuf, "Content-Type: application/pdf\r\n");
}
else if(!_stricmp(LastFourCharsOfFileName, ".exe") || !_stricmp(LastFourCharsOfFileName, ".dll"))
{
strcat(SendBuf, "Content-Type: application/x-msdownload; name=\"");
strcat(SendBuf, EncodedFileName.c_str());
strcat(SendBuf, "\"\r\n");
}
There are some issues with the above code:-
1. If the file extension is not .pdf, .exe or .dll then it doesn't use any mime type. I don't know
how spam filters will handle that.
2. I don't know if _stricmp works with Linux.
3. The file name is added with name=... I don't see that in the examples that I see online.
In my application we only send .pdf files so it doesn't matter.
|
|
|
|
|
Note that it is better to upgrade progressively (eg. to VS2015 then VS2019) rather than in one big step (in order for some defaults to come through correctly).
After upgrading the project to VS2015, VS2017 or VS2019:-
1. In Project Properties (for Debug), C/C++, All Options, Enable Minimal Build, Set to "No (/Gm-)"
2. In Project Properties (for Debug and Release), C/C++, Preprocessor, Add "_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;" (before %(PreprocessorDefinitions))
3. In Project Properties (for Debug and Release), Linker, Input, Additional Dependencies, Add "legacy_stdio_definitions.lib;" (before %(AdditionalDependencies))
4. In Project Properties (for Debug), Linker, Advanced, Image Has Safe Exception Handlers, Set to "No (/SAFESEH:NO)"
5. In main.cpp, after the two #defines at the top, add the following
extern "C" { FILE __iob_func[3] = {stdin,stdout,stderr}; }
6. In base64.cpp, replace "base64_chars.find" with "(unsigned char)base64_chars.find" in two places
7. In CSmtp.cpp, replace 'else recipient.Name.empty();' with 'else recipient.Name = "";' in three places
8. The project should now compile. If you are now getting a warning MSB4211, click View (menu at top), Other Windows, Property Manager, and delete "Upgrade from VC 6.0" (for Debug and Release)
see https:
And some tidy ups:
1. Delete the file CSmtp.vcproj (has been replaced with CSmtp.vcxproj)
2. Delete the file UpgradeLog.htm
3. In CSmtp.cpp, replace "http://www.codeproject.com" with "https://www.codeproject.com" (add the s to http)
4. In CSmtp.cpp, place a comment at the top "// Obtained from https://www.codeproject.com/Articles/98355/SMTP-Client-with-SSL-TLS" because the first three codeproject links are all dead links.
In my opinion, this project needs to be further upgraded by:-
1. Replacing legacy code with modern code (to get rid of _CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS; legacy_stdio_definitions.lib)
2. Converting it to 64 bit. The biggest issue will be getting the 64 bit versions of libeay32.lib and ssleay32.lib. Instructions on compiling a 64 bit version are at https:
3. Upgrade from openssl-0.9.8l to openssl-1.1.1. One disadvantage of upgrading the SSL library is that four support DLLs would now be required (two for 32 bit and two for 64 bit).
modified 28-Feb-21 17:45pm.
|
|
|
|
|
With Gmail (or Google Workspace) it is important to turn on "Access for less secure apps" otherwise you will get "Bad login or password". And to turn on "Access for less secure apps" you need to make sure that “2-Step Verification” is turned OFF.
For more information see SMTP Configuration[^]
|
|
|
|
|
I am getting an error while trying to include it in the additional dependencies section.
What static library do we have to include in the project
|
|
|
|
|
I used the latest version of the program, but when I sent it, I was prompted that I didn't set the address of the recipient. I have already set it. Undefined at least one receipent exception prompt is this. Why do I have this problem? Because of QQ email?
|
|
|
|
|
So I downloaded this code to help me with a project I am working on. I am using a software called putty to log me in to my schools server and use their c++. I transferred the files all except the visual studio ones and just as I was about to test it I get a message that says that CSmtp.h:26:26: fatal error: openssl/ssl.h: No such file or directory
#include <openssl ssl.h="">
I moved the files around, tried making it a direct path (like having it openssl-0.9.8l/inc32/openssl/ssl.h) and tried having just the ssl.h file be in the same directory as the CSmtp.h file but nothing works. Can someone try to help me with this issue? I really want to see if this thing can work but I can't get past the compiling stage and that is literally the only issue so far.
|
|
|
|
|
Is the timezone header missing? Since it is mentionend in the comment.
snprintf(header, BUFFER_SIZE, "Date: %d %s %d %d:%d:%d\r\n", timeinfo->tm_mday,
month[timeinfo->tm_mon], timeinfo->tm_year+1900, timeinfo->tm_hour,
timeinfo->tm_min, timeinfo->tm_sec);
Regards
|
|
|
|
|