CPJNSMTPConnection
v3.28
Welcome to CPJNSMTPConnection, a collection of C++ classes to
support the SMTP protocol. SMTP for those not familiar with all the internet protocols
is the protocol used to send internet email.
Also included with the SMTP classes in the download is a class called "CPJNMD5Hash"
which provides for calculation of MD5 hashes and HMACs using the MS Crypto API as
well as a class called "CNTLMClientAuth" which provides a reusable client
side implementation for NTLM authentication.
Important!: Please note that I have been informed that CPJNSMTPConnection
is being used to develop and send unsolicited bulk mail. This was not the intention
of the code and the author explicitly forbids use of the code for any software of
this kind without my explicit written consent.
References
- For information about SMTP (Simple
Mail Transfer Protocol) you
should read RFC 5321.
- For information about ESMTP (Extended Simple Mail Transfer Protocol) which
obsoletes the original SMTP RFC, you should read
RFC 2821.
- RFC 2045 which defines
how MIME attachments are to be handled in a standard SMTP message.
- RFC 2110 and
RFC 2557 which covers MHTML
(aka HTML Email).
- Base64 encoding which is used in various places in SMTP/POP3 is described
in RFC 4648
- The details about SMTP authentication are spread across a number of RFCs
including RFC 1731,
RFC 1869,
RFC 2195,
RFC 2095,
RFC 2245,
RFC 2554,
RFC 2595,
RFC 4616 and
RFC 4954.
- The CRAM-MD5 authentication scheme uses a HMAC (Hashed Message Authentication
Code) which is described in RFC
2104, while MD5 itself is described in
RFC 1321.
- RFC 3461,
RFC 3464 ,
RFC 3798 and
RFC 3885 describe DSN's
(Delivery Status Notifications) and MDN's (Message Disposition Notifications)
- The page
http://www.activexperts.com/support/activemail/auth/ includes a good description
of the AUTH LOGIN, AUTH PLAIN and AUTH CRAM-MD5 authentication schemes which
is implemented by CPJNSMTPConnection.
- RFC 3207 define how STARTTLS
operates.
- https://developers.google.com/gmail/xoauth2_protocol
defines the XOAUTH2 Authentication protocol when used with the Gmail SMTP servers.
- Initial Client Response (SASL-IR) support is described in
RFC 4959.
Features
- Simple and clean C++ interface.
- The interface provided is synchronous which provides an easier programming
model than using asynchronous sockets.
- The code does not rely on the MFC socket classes. These classes have a number
of shortcomings, one of which causes problems when they are used in NT services.
- The code can be used in a console application without any problems.
- A configurable timeout for the connection can be set through the class API.
- The classes are fully Unicode compliant and include Unicode built options
in the workspace file.
- As of v1.1, the classes now fully supports sending file attachments.
- Multi CC, BCC & Reply To support is included.
- Support for regular email address formats and multiple email address parsing.
- Full support for MIME and MHTML (aka HTML Email).
- Full support for MIME Charsets.
- Comprehensive sample program included which exercises most of the classes
functionality.
- As of v2.61, the classes now fully support sending email over SSL. This
means that for instance you can use the Gmail SMTP server "smtp.gmail.com"
on port 465. Also note that all of the other features such as authentication
are fully supported over SSL. For example to use Gmail you will require some
form of authentication such as AUTH PLAIN because it does not operate as an
open relay (which would facilitate spam).
- Supports numerous authentication protocols including "AUTH CRAM-MD5", "AUTH
LOGIN", "AUTH PLAIN", "AUTH NTLM" & "AUTH
XOAUTH2". An "Auto Detection" form of authentication is also
supported. In this mode, the authentication protocols supported by the server
are detected and the most appropriate protocol is used.
- As of v2.65, the classes include comprehensive support for DSN's (Delivery
Status Notifications).
- As of v2.84, the classes include support for MDN's (Message Disposition
Notifications)
- As of v2.86, the classes support STARTTLS. This SMTP command allows a standard
SMTP plain text connection to be made and assuming the SMTP server supports
STARTTLS, the connection can be upgraded to a encrypted connection mid stream.
Often SMTP servers only offer STARTTLS via port 25 instead of SSL / TLS on a
different port.
- Optionally supports Address header encoding.
- As of v3.09, the classes are only supported on VC 2013 or later.
- As of v3.18, the SMTP classes can now optionally compile without MFC. By
default the classes now use STL classes and idioms but if you define CWSOCKET_MFC_EXTENSIONS
the classes will revert back to the MFC behaviour.
- As of v3.21, the SMTP classes now support Initial Client Response (SASL-IR).
Copyright
- You are allowed to include the source code in any product (commercial, shareware,
freeware or otherwise) when your product is released in binary form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to maintain
a single distribution point for the source code.
- Important!!: Please note that I have been informed that CPJNSMTPConnection
is being used to develop and send unsolicited bulk mail. This was not the intention
of the code and the author explicitly forbids use of the code for any software
of this kind without my explicit written consent.
Usage
- The classes are designed for VC 2013 or later. They will not compile on
earlier releases of VC, so please no more emails about Visual C 6 support!
- You will also need to download the SocMFC.cpp/h modules separately from
www.naughter.com/w3mfc.html.
This set of modules provides the socket functionality.
- To use the class in your code simply include PJNSMTP.cpp/h, SocMFC.cpp/h
and PJNMD5.h in your project and #include PJNSMTP.h in which ever of your modules
needs to make calls to the classes. You also need to copy all the IDS_PJNSMTP_*
strings from the samples apps "PJNSMTP.rc" rc file to your applications
rc file.
- By default NTLM authentication is also provided for. This is provided by
including PJNNTLMAuth.cpp/h in your project. If you do not want to include this
support, then you should define the pre-processor macro "CPJNSMTP_NONTLM"
before including PJNSMTP.h. You then do not need to include these two modules
in your project.
- By default SSL connections are also provided for. This is provided by the
author's SSLWrappers classes which you will need to download from
http://www.naughter.com/sslwrappers.html.
Please note that the the SSLWrappers classes themselves depends on the author's
CryptoWrappers classes which you will also need to download from
http://www.naughter.com/cryptowrappers.html.
If you do not want to include SSL support, then you should define the pre-processor
macro "CPJNSMTP_NOSSL" before including PJNSMTP.h.
- You will need to have Winsock correctly initialised prior to calling any
functions in CPJNSMTPConnection. Depending on your application, this will involve
calling either WSAStartup or AfxSocketInit at start-up of your application.
- To see the class in action, have a look at the code in CPJNSMTPApp::InitInstance
in the module "PJNSMTPApp.cpp" as well as all the code in the PJNSMTPAppDlg.cpp
module in the sample application which comes with the code. For example to send
a message about this class, the code would look something like this (ignoring
error handling<gg>):
CPJNSMTPConnection smtp;
smtp.Connect(_T("mail.someisp.com"));
CPJNSMTPMessage m;
CPJNSMTPAddress toAddress(_T("someaddress@somedestination.com"));
m.m_To.Add(toAddress);
m.m_From = CPJNSMTPAddress(_T("adeveloper@someisp.com"));
m.m_sSubject = _T("A Fellow developer!");
m.AddTextBody(_T("If you can read this then the CPJNSMTPConnection code is working"));
smtp.SendMessage(m);
History
V3.28 (18 December 2017)
- Updated the code to compile cleanly when _ATL_NO_AUTOMATIC_NAMESPACE is
defined.
V3.27 (9 September 2017)
- Replaced CString::operator LPC*STR() calls throughout the codebase with
CString::GetString calls.
V3.26 (2 May 2017)
- Fixed a bug in the CNTLMClientAuth::NTLMAuthenticate method when CNTLMCLIENTAUTH_MFC_EXTENSIONS
is defined. Thanks to Darron Redman for reporting this issue.
V3.25 (28 April 2017)
- Updated the code to compile cleanly using /permissive-.
V3.24 (14 April 2017)
- Updated copyright details.
- Updated code to compile cleanly on VC 2017
V3.23 (14 November 2016)
- Updated the non MFC code path in CNTLMClientAuth::NTLMAuthenticate to handle
a NULL pszUsername parameter being passed. Thanks to Christopher Craft for reporting
this issue.
- Removed unnecessary validation of pszUsername & pszPassword parameters in
CPJNSMTPConnection::ConnectESMTP. Thanks to Christopher Craft for reporting
this issue.
- Added validation of pszUsername & pszPassword parameters in CPJNSMTPConnection::AuthLogin,
CPJNSMTPConnection::AuthPlain & CPJNSMTPConnection::AuthCramMD5 methods. Thanks
to Christopher Craft for reporting this issue.
- Improved the SAL annotations on the CPJNSMTPConnection::ConnectESMTP method
- Reworked CPJNSMTPBodyPart::ConvertToUTF8 to use ATL::CW2A
V3.22 (13 October 2016)
- Fixed a bug in the declaration of the CPJNSMTPConnection class when the
CPJNSMTP_NONTLM preprocessor value is defined. Thanks to Chris Korda for reporting
this issue.
- Provided a new overload of the CPJNSMTPBodyPart::AddChildBodyPart method
to allow an already heap allocated bodyPart to be added.
- Provided a new overload of the CPJNSMTPBodyPart::InsertChildBodyPart method
to allow an already heap allocated bodyPart to be added.
- Made most of the methods of CPJNSMTPBodyPart virtual to allow for easier
end user customization of its functionality.
- Provided a new overload of the CPJNSMTPMessage::AddChildBodyPart method
to allow an already heap allocated bodyPart to be added.
- Provided a new overload of the CPJNSMTPMessage::InsertChildBodyPart method
to allow an already heap allocated bodyPart to be added.
- Made most of the methods of CPJNSMTPMessage virtual to allow for easier
end user customization of its functionality.
V3.21 (19 September 2016)
- Added support for XOAUTH2 authentication. For more information about this
SMTP authentication mechanism please see
https://developers.google.com/gmail/xoauth2_protocol.
- Reworked the CPJNSMTPConnection::AuthPlain to provide the userid in the
authorization identity value. This is a more compatible form of the auth request
and avoids issues using AuthPlain against the gmail SMTP servers.
- Added Initial Client Response (SASL-IR) support to the AuthLogin, AuthPlain &
AuthXOAUTH2 methods. For more information about SASL-IR please see
https://tools.ietf.org/html/rfc4959.
V3.20 (19 August 2016)
- Reworked the CPJNSMTPException::GetErrorMessage to not bother putting the
last response into the return error message text.
- CPJNSMTPConnection class is now protected inherited from SSLWrappers::CSocket.
V3.19 (17 August 2016)
- Reworked CPJNSMTPConnection class to be inherited from SSLWrappers::CSocket.
This allows for easier overloading of the various SSLWrappers class framework
virtual functions
V3.18 (11 August 2016)
- Reworked the SMTP classes to optionally compile without MFC. By default
the classes now use STL classes and idioms but if you define CWSOCKET_MFC_EXTENSIONS
the classes will revert back to the MFC behaviour.
- Reworked the CPJNSMPTBase64Encode class to use ATL::CHeapPtr.
- Reworked the CPJNSMPTQPEncode class to use ATL::CHeapPtr.
- Reworked the CPJNSMPTQEncode class to use ATL::CHeapPtr.
- Added SAL annotations to all the code.
- CPJNSMTPBodyPart::ConvertToUTF8 now internally uses ATL::CHeapPtr.
- The CPJNSMTPMessage::m_CustomHeaders member variable is now public. As such
the AddCustomHeader, GetCustomHeader, GetNumberOfCustomHeaders & RemoveCustomHeader
methods have been removed.
- Removed unnecessary code which catches and rethrows a CPJNSMTPException
exception from the version of CPJNSMTPConnection::SendMessage which sends a
message from a memory buffer.
- Reworked the CPJNSMTPMessage::ParseMultipleRecipients method to avoid the
use of the C++ new allocator.
- Reworked the CPJNSMTPMessage::AddMultipleAttachments method to avoid the
use of the C++ new allocator.
- Reworked the sample app to exercise the SendMessage method which sends from
a memory buffer.
- Removed defunct comments about VC 6 in CPJNMD5 class.
- Reworked the CPJNMD5 class to optionally compile without MFC. By default
the class now uses STL classes and idioms but if you define CPJNMD5_MFC_EXTENSIONS
the classes will revert back to the MFC behaviour.
- Reworked the CNTLMClientAuth class to optionally compile without MFC. By
default the class now uses STL classes and idioms but if you define CNTLMCLIENTAUTH_MFC_EXTENSIONS
the class will revert back to the MFC behaviour.
V3.17 (12 May 2016)
- Updated copyright details.
- Minor update to the sample app to refer to "SSL / TLS" in the
configuration dialog.
- Verfied the code compiles cleanly using VC 2015.
V3.16 (1 June 2015)
- Removed unused CPJNSMTPMessage::ConvertHTMLToPlainText method.
- Removed the linkage in the test app's configuration dialog between sending
a message with a HTML body and requiring that the message is MIME encoded.
- Removed the code from the test app which added a plain text attachment to
the message in debug builds.
- Updated CPJNSMTPMessage::AddHTMLBody to handle the case where the message
is not MIME encoded. In this case the root body part of the message is simply
set to HTML. Thanks to Thane Hubbell for reporting this issue.
V3.15 (29 March 2015)
- Updated CPJNSMTPConnection::AuthLogin to handle more variants of "username:"
and "password:" SMTP server responses. Thanks to Wang Le for reporting
this issue.
V3.14 (1 March 2015)
- The DoEHLO method has been updated to check for DSN requirements. This change
means that the code will connect with a EHLO instead of HELO when a DSN is requested.
The code will now also check whether DSN's are supported by the server when
attempting to send the DSN. If the server does not support DSN's in this scenario
then a new custom exception will be thrown by the code in the CPJNSMTPConnection::FormMailFromCommand
method. This ensures the code behaves more consistently with respect to the
DSN RFC. Thanks to Philip Mitchell for prompting this update.
- Change the enum value for CPJNSMTPMessage::DSN_NOT_SPECIFIED to 0 from 0xFFFFFFFF.
V3.13 (31 January 2015)
- Fixed an error in CPJNSMTPException::GetErrorMessage where it would not
use the full HRESULT value when calling FormatMessage. Thanks to Bostjan Erzen
for reporting this issue.
- Improved the error handling in CPJNSMTPConnection::Connect when SSL connection
errors occur. Thanks to Bostjan Erzen for reporting this issue.
- Improved the error handling in CPJNSMTPConnection::DoSTARTTLS when SSL connection
errors occur. Thanks to Bostjan Erzen for reporting this issue.
V3.12 (25 January 2015)
- Addition of CPJNSMTPBodyPart::InsertChildBodyPart and CPJNSMTPMessage::InsertBodyPart
methods. These new methods inserts a body part as the first element in the hierarchy
of child body parts instead of to the end. In addition the CPJNSMTPMessage::AddTextBody
and CPJNSMTPMessage::AddHTMLBody methods now call CPJNSMTPBodyPart::InsertChildBodyPart
instead of CPJNSMTPBodyPart::AddChildBodyPart to ensure that the body text part
of the SMTP message appears as the first child body part. This helps avoid issues
where Microsoft Exchange modifies multipart messages where the body text is
moved to an attachment called ATT00001: For further information please see
http://kb.mit.edu/confluence/pages/viewpage.action?pageId=4981187 and
http://support2.microsoft.com/kb/969854.
Thanks to Marco Veldman for reporting this issue.
- Removed support for DTLSv1 SSL protocol as this is not applicable to SMTP
as DTLS is designed for UDP and not TCP. This removal helps resolve an issue
where the code did not compile in VC 2013 if you used the "Visual Studio
2013 - Windows XP (v120_xp)" Platform Toolset. Thanks to Bostjan Erzen
for reporting this issue.
V3.11 (16 January 2015)
- Updated copyright details
- CPJNSMTPMessage::m_ReplyTo is now an array instead of a single address.
Thanks to Bostjan Erzen for suggesting this update.
V3.10 (16 December 2014)
- Updated the code to use the latest v1.03 version of SSLWrappers
V3.09 (14 December 2014)
- Updated the code to use the author's SSLWrappers classes (http://www.naughter.com/sslwrappers.html)
to provide the SSL functionality for PJNSMTP instead of OpenSSL. Please note
that the the PJNSMTP code when in SSL mode depends on the author's CryptoWrappers
classes (http://www.naughter.com/cryptowrappers.html)
also. You will need to download both of these libraries and copy their modules
into the PJNSMTP directory. Also note that the SSLWrappers and CryptoWrapper
classes are only supported on VC 2013 or later and this means that the PJNSMTP
SSL support is only supported when you compile with VC 2013 or later. The solution
files included in the PJNSMTP download are now for VC 2013.
- With the change to using SSLWrappers, the code can now support additional
flavours of SSL protocol. They are: SSL v2 on its own, SSL v3 on its own, The
OS SChannel SSL default and AnyTLS. Please see the CPJNSMTPConnection::SSLProtocol
enum for more details. The sample app has been updated to allow these values
to be used and the default enum value is now "OSDefault".
V3.08 (18 November 2014)
- Fixed a bug in CPJNSMTPBodyPart::GetBody where file attachments were always
being treated as 0 in size. Thanks to Oliver Pfister for reporting this issue.
V3.07 (15 November 2014)
- CNTLMClientAuth now takes a static dependency on Secure32.dll instead of
using GetProcAddress.
- The CNTLMClientAuth now calls QuerySecurityPackageInfo to determine the
buffer size to use.
- The SEC_SUCCESS macro has now been made a method called "SEC_SUCCESS".
- General cleanup of the CNTLMClientAuth::GenClientContext method
- Made the CNTLMClientAuth destructor virtual.
- Removed the defunct method CPJNSMTPBodyPart::HexDigit.
- Reworked the CPJNSMTPBodyPart::GetBody method to use ATL::CAtlFile and ATL::CHeapPtr
- CPJNSMTPConnection now takes a static dependency on Wininet.dll instead
of using GetProcAddress.
- CPJNSMTPConnection now takes a static dependency on Dnsapi.dll instead of
using GetProcAddress.
- The default timeout set in the CPJNSMTPConnection constructor is now 60
seconds for both debug and release builds
- Removed the now defunct CPJNSMTPConnection::MXLookupAvailable method
- Removed the now defunct CPJNSMTP_NOMXLOOKUP preprocessor value
- Removed the now defunct PJNLoadLibraryFromSystem32.h module from the distribution
- CPJNSMTPConnection::SendMessage has been reworked to use ATL::CAtlFile and
ATL::CHeapPtr
- CPJNSMTPConnection::SendMessage now does a UTF-8 conversion on the body
of the email when sending a plain email i.e. no HTML or mime if the charset
is UTF-8. Thanks to Oliver Pfister for reporting this issue.
- Sample app has been updated to compile cleanly on VS 2013 Update 3 and higher
- The sample app shipped with the source code is now Visual Studio 2008 and
as of this release the code is only supported on Visual Studio 2008 and later
- The sample app is now linked against the latest OpenSSL v1.0.1j dlls
V3.06 (13 April 2014)
V3.05 (9 February 2014)
- Fixed a compile problem in the CreateSSLSocket method when the CPJNSMTP_NOSSL
preprocessor macro is defined.
- Reworked the logic which does SecureZeroMemory on sensitive string data
V3.04 (26 January 2014)
- Updated ASSERT logic at the top of the ConnectESMTP method. Thanks to Jean-Christophe
Voogden for reporting this issue.
V3.03 (5 January 2014)
- The ConvertToUTF8 method now also handles conversion of ASCII data to UTF8.
Thanks to Jean-Christophe Voogden for this update.
- The CPJNSMTPConnection class now provides Set/GetSSLProtocol methods. This
allows client code to specify the exact flavour of SSL which the code should
speak. Supported protocols are SSL v2/v3, TLS v1.0, TLS v1.1, TLS v1.2 and DTLS
v1.0. This is required for some SMTP servers which use the SSLv2 or v3 protocol
instead of the more modern TLS v1 protocol. The default is to use TLS v1.0.
You may need to use this compatibility setting for the likes of IBM Domino SMTP
servers which only support the older SSLv2/v3 setting. Thanks to Jean-Christophe
Voogden for this update.
- Removed all the proxy connection methods as they cannot be easily supported
/ tested by the author.
- Reworked the code in CPJNSMTPConnection::ConnectESMTP to handle all variants
of the 250 response as well as operate case insensitively which is required
by the ESMTP RFC.
- Made more methods virtual to facilitate further client customisation
- Fixed an issue in the DoSTARTTLS method where the socket would be left in
a connected state if SSL negotiation failed. This would result in later code
which sent on the socket during the tear down phase hanging. Thanks to Jean-Christophe
Voogden for reporting this issue.
- The sample app is now linked against the latest OpenSSL v1.0.1f dlls.
V3.02 (5 January 2014)
- Updated copyright details.
- Updated the code to clean compile on VC 2013
- Fixed a problem with NTLM auth where the code did not correctly set the "m_nSize"
parameter value correctly in CPJNSMPTBase64Encode::Encode & Decode. Thanks
to John Pendleton for reporting this bug.
7 June 2013
- Minor update to the sample app to fix a spelling mistake in the connection
type string in the configuration dialog. Thanks to "don" for reporting
this issue.
V3.01 (3 June 2013)
- The demo app now disables the MIME checkbox after checking it if the email
is to be sent as HTML.
- Fixed a bug in the sample app where the mime type of the root body part
would be incorrectly set to an empty string when it should use the default which
is "multipart/mixed". Thanks to Ting L for reporting this bug.
V3.00 (12 March 2013)
- Updated copyright details.
- CPJNSMTPAddressArray typedef is now defined in the CPJNSMTPMessage class
instead of in the global namespace. In addition this typedef class is now known
as "CAddressArray"
- The sample project included in the download now links to the various OpenSSL
libraries via defines in stdafx.h instead of via project settings. Thanks to
Ed Nafziger for suggesting this nice addition.
- The sample app no longer adds the author's hotmail address to the list
of MDN's. Thanks to Ed Nafziger for spotting this.
- The sample app is now linked against the latest OpenSSL v1.0.1e dlls.
- Sample app now statically links to MFC
V2.99 (25 November 2012)
- Fixed some issues in the code when CPJNSMTP_NOSSL was defined. Looks like
support for compiling without SSL support has been broken for a few versions.
Thanks to Bostjan Erzen for reporting this issue.
V2.98 (30 September 2012)
- Updated the code to avoid DLL planting security issues when calling LoadLibrary.
Thanks to Mat Berchtold for reporting this issue.
- A header file called "PJNLoadLibraryFromSystem32.h" is now included
which provides a version of LoadLibrary which loads a DLL without any path information
from the Windows System directory. This helps avoid DLL planting security issues
in your application when you call LoadLibrary with a module name without any
path information.
V2.97 (24 September 2012)
- Removed an unnecessary line of code from CPJNSMTPConnection::SendRCPTForRecipient.
Thanks to Mat Berchtold for reporting this issue.
V2.96 (23 September 2012)
- Removed SetContentBase and GetContentBase methods as Content-Base header
is deprecated from MHTML. For details see
http://www.ietf.org/mail-archive/web/apps-discuss/current/msg03220.html.
Thanks to Mat Berchtold for reporting this issue.
- Removed the now defunct parameter from the AddHTMLBody method.
- Removed the FoldHeader method as it was only used by the m_sXMailer header.
- Updated the logic in the FolderSubjectHeader method to correctly handle
the last line of text to fold.
V2.95 (12 August 2012)
- STARTTLS support code now uses TLSv1_client_method OpenSSL function instead
of SSLv23_client_method. This fixes a problem where sending emails using Hotmail
/ Windows Live was failing.
- CPJNSMTPConnection::_Close now provides a bGracefully parameter
- Updated the code to clean compile on VC 2012
- The sample app is now linked against the latst OpenSSL v1.0.1c dlls.
- SendMessage now throws a CPJNSMTPException if OnSendProgress returns FALSE.
- Addition of a new ConnectionType called "AutoUpgradeToSTARTTLS"
which will automatically upgrade a plain text connection to STARTTLS if the
code detects that the SMTP server supports STARTTLS. If the server doesn't
support STARTTLS then the connection will remain as if you specified "PlainText"
- Reworked the code to determine if it should connect using EHLO instead of
HELO into a new virtual method called DoEHLO.
- Reworked the internals of the ConnectESMTP method.
V2.94 (4 December 2011)
- Updated CPJNSMTPBodyPart::GetHeader to encode the title of a filename if
it contains non-ASCII characters. Thanks to Anders Gustafsson for reporting
this issue.
- The sample app is now linked against the latst OpenSSL v1.0.0e dlls.
V2.93 (1 April 2011)
- Reintroduced the concept of Address Header encoding. By default this setting
is off, but can be enabled via a new CPJNSMPTMessage::m_bAddressHeaderEncoding
boolean value. Thanks to Bostjan Erzen for reporting this issue.
- The sample app is now linked against the latest OpenSSL v1.0.0d dlls.
V2.92 (13 February 2011)
- Remove the IP binding address parameter from the Connect method as there
was already support for binding via the Set/GetBoundAddress methods.
- Set/GetBoundAddress have been renamed Set/GetBindAddress for consistency
with the sockets class
V2.91 (8 February 2011)
- Updated copyright details
- Updated code to support latest SSL and Sockets class from the author. This
means that the code now supports IPv6 SMTP servers
- Connect method now allows binding to a specific IP address
V2.90 (18 December 2010)
- Removed the methods Set/GetQuotedPrintable and Set/GetBase64 from CPJNSMTPBodyPart
and replaced them with new Set/GetContentTransferEncoding methods which works
with a simple enum.
- CPJNSMTPBodyPart::SetAttachment and CPJNSMTPBodyPart::SetFilename now automatically
sets the Content-Transfer-Encoding to base64 for attachments. Thanks to Christian
Egging for reporting this issue.
- The sample app is now linked against the latest OpenSSL v1.0.0c dlls
V2.89 (28 November 2010)
- AddTextBody and AddHTMLBody now allow the root body part's MIME type
to be changed. Thanks to Thane Hubbell for prompting this update.
- Added a CPJNSMTPBodyPart::GetBoundary method.
- Added some sample code to the sample app's CPJNSMTPAppDlg constructor
to show how to create a message used SMTP body parts. Thanks to Thane Hubbell
for prompting this update.
- CPJNSMTPBodyPart::GetHeader now allows quoted-printable and raw attachments
to be used
- The sample app is now linked against the latest OpenSSL v1.0.0b dlls
V2.88 (10 July 2010)
- Following feedback from multiple users of PJNSMTP, including Chris Bamford
and "loggerlogger", the change from "multipart/mixed" to "multipart/alternative"
has now been reverted. Using "multipart/mixed" is a more appropriate
value to use. Testing by various clients have shown that this setting works
correctly when sending HTML based email in GMail, Thunderbird and Outlook. Unfortunately
this is the price I must pay when accepting end user contributions to my code
base which I cannot easily test. Going forward I plan to be much more discerning
on what modifications I will accept to avoid these issues.
- The CPJNSMTPBodyPart now has the concept of whether or not the body is considered
an attachment. Previously the code assumed that if you set the m_sFilename parameter
that the body part was an attachment. Instead now the code uses the "m_bAttachment"
member variable. This allows an in memory representation of an attachment to
be added to a message without the need to write it to an intermediate file first.
For example, here would be the series of steps you would need to go through
to add an in memory jpeg image to an email and have it appear as an attachment:
const BYTE* pInMemoryImage = pointer to your image;
DWORD dwMemoryImageSize
= size in bytes of pInMemoryImage;
CPJNSMPTBase64Encode encode;
encode.Encode(pInMemoryImage,
dwMemoryImageSize, ATL_BASE64_FLAG_NONE);
CPJNSMTPBodyPart imageBodyPart;
imageBodyPart.SetRawBody(encode.Result());
imageBodyPart.SetBase64(TRUE);
imageBodyPart.SetAttachment(TRUE);
imageBodyPart.SetContentType(_T("image/jpg"));
imageBodyPart.SetTitle(_T("the name of the image"));
CPJNSMTPMessage
message;
message.AddBodyPart(imageBodyPart);
Thanks to Stephan Eizinga
for suggesting this nice addition.
V2.87 (4 June 2010)
- Updated the code and sample app to compile cleanly when CPJNSMTP_NOSSL is
defined. Thanks to "loggerlogger" for reporting this issue.
V2.86 (23 May 2010)
- Updated copyright details
- Updated sample app to compile cleanly on Visual Studio 2010
- The sample app is now linked against the latest OpenSSL v1.0.0 dlls
- Removed an unused "sRet" variable in CPJNSMTPConnection::AuthCramMD5.
Thanks to Alain Danteny for reporting this issue
- Replaced all calls to memcpy with memcpy_s
- The code now supports STARTTLS encryption as defined in RFC 3207
- If the call to DnsQuery fails, the error value is now preserved using SetLastError
- AddTextBody now sets the mime type of the root body part multipart/alternative.
This is a more appropriate value to use which is better supported by more email
clients. Thanks to Thane Hubbell for reporting this issue.
V2.85 (17 December 2009)
- The sample app is now linked against the latest OpenSSL v0.9.8l dlls
- Updated the sample code in the documentation to better describe how to use
the various classes. Thanks to Dionisis Kofos for reporting this issue.
V2.84 (13 November 2009)
- Now includes comprehensive support for MDN's (Message Disposition Notifications)
as specified in RFC 3798. Thanks to Ron Brunton for prompting this update.
- Rewrote CPJNSMTPMessage::SaveToDisk method to use CAtlFile
V2.83 (28 June 2009)
- Updated copyright details
- Fixed a bug where the Reply-To email address was not correctly added to
the message. Thanks to Dmitriy Maksimov for reporting this issue.
- Updated the sample app's project settings to more modern default values.
- Updated the sample exe to ship with OpenSSL v0.98k
- Fixed a bug in CPJNSMTPConnection::SendBodyPart where it would cause errors
from OpenSSL when trying to send a body of 0 bytes in size. This can occur when
MHTML based emails are sent and you are using a "multipart/related"
body part. Thanks to "atota" for reporting this issue
V2.82 (6 November 2008)
- For best compatibility purposes with existing SMTP mail servers, all message
headers which include email addresses are now not Q encoded. Thanks to Christian
Egging for reporting this issue.
- Optimized use of CT2A class throughout the code
V2.81 (2 November 2008)
- Improvements to CPJNSMTPAddress constructor which takes a single string.
The code now removes redundant quotes.
- CPJNSMTPAddress::GetRegularFormat now forms the regular form of the email
address before it Q encodes it.
- The sample app now uses DPAPI to encrypt the username & password configuration
settings.
- The sample app is now linked against the latest OpenSSL v0.9.8i dlls.
- Updated coding references in the html documentation. In addition the zip
file now includes the OpenSSL dlls. Thanks to Michael Grove for reporting this
issues.
V2.80 (16 August 2008)
- Updated the AUTH_AUTO login support to fall back to no authentication if
no authentication scheme is supported by the SMTP server. Thanks to Mat Berchtold
for this update.
V2.79 (27 July 2008)
- Updated code to compile correctly using _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
define
- CPJNSMTPMessage::GetHeader now correctly ensures all long headers are properly
folded. In addition this function has been reworked to create the header internally
as an ASCII string rather than as a TCHAR style CString.
V2.78 (20 July 2008)
- Fixed a bug in ReadResponse where the code is determining if it has received
the terminator. Thanks to Tony Cool for reporting this bug.
V2.77 (31 May 2008)
- Code now compiles cleanly using Code Analysis (/analyze)
- Removed the use of the function QuotedPrintableEncode and replaced with
ATL::QPEncode
- Removed the use of the function QEncode and replaced with ATL::QEncode
- Reworked ReadResponse to use CStringA in line with the implementation in
the POP3 class of the author.
V2.76 (1 March 2008)
- CPJNSMTP Priority enum values, specifically NO_PRIORITY have been renamed
to avoid clashing with a #define of the same name in the Windows SDK header
file WinSpool.h. The enum values for DSN_RETURN_TYPE have also been renamed
to maintain consistency. Thanks to Zoran Buntic for reporting this issue.
- Fixed compile problems related to the recent changes in the Base64 class.
Thanks to Mat Berchtold for reporting this issue.
- Since the code is now for VC 2005 or later only, the code now uses the Base64
encoding support from the ATL atlenc.h header file. Thanks to Mat Berchtold
for reporting this optimization. This means that client projects no longer need
to include Base64.cpp/h in their projects.
V2.75 (2 February 2008)
- Updated copyright details.
- Fixed a bug in CPJNSMTPMessage::FormDateHeader where sometimes an invalid "Date:"
header is created. The bug will manifest itself for anywhere that is ahead of
GMT, where the difference isn't a multiple of one hour. According to the
Windows Time Zone applet, this bug would have occured in: Tehran, Kabul, Chennai,
Kolkata, Mumbai, New Delhi, Sri Jayawardenepura, Kathmandu, Yangon, Adelaide
and Darwin. Thanks to Selwyn Stevens for reporting this bug and providing the
fix.
V2.74 (31 December 2007)
- Updated the sample app to clean compile on VC 2008
- Fixed a x64 compile problems in RemoveCustomHeader & AddMultipleAttachments.
- Fixed a x64 compile problem in CPJNSMTPAppConfigurationDlg::CBAddStringAndData
- CPJNSMTPException::GetErrorMessage now uses Checked::tcsncpy_s
- Other Minor coding updates to CPJNSMTPException::GetErrorMessage
V2.73 (24 December 2007)
- CPJNSMTPException::GetErrorMessage now uses the FORMAT_MESSAGE_IGNORE_INSERTS
flag. For more information please see Raymond Chen's blog at
http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx. Thanks
to Alexey Kuznetsov for reporting this issue.
- All username and password temp strings are now securely destroyed using
SecureZeroMemory.
V2.72 (23 December 2007)
- Following feedback from Selwyn Stevens that the AUTH PLAIN mechanism was
failing for him while trying to send mail using the gmail SMTP server, I decided
to go back and re-research the area of SMTP authentication again<g>. It
turns out that the way I was implementing AUTH PLAIN support was not the same
as that specified in the relevant RFCs. The code has now been updated to be
compliant with that specified in the RFC. I've confirmed the fix as operating
correctly by using the gmail SMTP mail server at "smtp.gmail.com"
on the SMTP/SSL port of 465. I've also taken the opportunity to update the
documentation to include a section with links to various RFC's and web pages
for background reference material
V2.71 (19 November 2007)
V2.70 (13 November 2007)
- Major update to the code to use VC2005 specific features. This version of
the code and onwards will be supported only on VC 2005 or later. Thanks to Andrey
Babushkin for prompting this update. Please note that there has been breaking
changes to the names and layout of various methods and member variables. You
should carefully analyze the sample app included in the download as well as
your client code for the required updates you will need to make.
- Sample app included in download is now build for Unicode and links dynamically
to MFC. It also links dynamically to the latest OpenSSL 0.9.8g dlls.
V2.67 (1 August 2007)
- AuthCramMD5, ConnectESMTP, ConnectSMTP, AuthLogin, and AuthPlain methods
have now been made virtual.
- Now includes support for a Auto Authentication protocol. This will detect
what authentication methods the SMTP server supports and uses the "most
secure" method available. If you do not agree with the order in which the
protocol is chosen, a virtual function called "ChooseAuthenticationMethod"
has been provided. Thanks to "zhangbo" for providing this very nice
addition to the code.
- Removed the definition for the defunct "AuthNTLM" method.
V2.66 (30 March 2007)
- Fixed a bug in CPJNSMTPConnection::SetHeloHostname where an unitialized
stack variable could potentially be used. Thanks to Anthony Kowalski for reporting
this bug.
- Updated copyright details.
V2.65 (11 November 2006)
- Reverted CPJNSMTPException::GetErrorMessage to use the system default locale.
This is consistent with how MFC does its own error handling.
- Now includes comprehensive support for DSN's (Delivery Status Notifications)
as specified in RFC 3461. Thanks to Riccardo Raccuglia for prompting this update.
- CPJNSMTPBodyPart::GetBody and CPJNSMTPConnection::SendMessage(const CString&
sMessageOnFile... now does not open the disk file for exclusive read access,
meaning that other apps can read from the file. Thanks to Wouter Demuynck for
reporting this issue.
- Fixed an issue in CPJNSMTPConnection::SendMessage(const CString& sMessageOnFile...
where under certain circumstances we could end up deleting the local "pSendBuf"
buffer twice. Thanks to Izidor Rozman for reporting this issue.
V2.64 (13 October 2006)
- Code now initializes the Domain name value in CNTLMClientAuth::NTLMAuthenticate
to an empty string instead of a NULL string. This avoids NTLM authentication
issues when authenticating as a non-domain user with certain mail servers. Thanks
to Wouter Demuynck for reporting this issue.
- Fixed an issue in Disconnect where if the call to ReadCommandResponse threw
an exception, we would not close down the socket or set m_bConnected to FALSE.
The code has been updated to ensure these are now done. This just provides a
more consistent debugging experience. Thanks to Alexey Kuznetsov for reporting
this issue.
- CPJNSMTPException::GetErrorMessage now uses the user default locale for
formatting error strings.
- Fixed some issues with cleaning up of header and body parts in CPJNSMTPConnection::SendBodyPart
and CPJNSMTPMessage::WriteToDisk. Thanks to Xiao-li Ling for reporting this
issue.
17 July 2006
- Updated the code in the sample app to allow > 30000 characters to be
entered into the edit box which contains the body of the email. This is achieved
by placing a call to CEdit::SetLimitText in the OnInitDialog method of the dialog.
Thanks to Thomas Noone for reporting this issue.
V2.63 (14 July 2006)
- Fixed a bug in CPJNSMTPConnection where when compiled in UNICODE mode, NTLM
authentication would fail. Thanks to Wouter Demuynck for providing the fix for
this bug.
- Reworked the CPJNSMTPConnection::NTLMAuthPhase(*) methods to throw standard
CPJNSMTPException exceptions if there are any problems detected. This can be
done now that the CNTLMClientAuth class is resilient to exceptions being thrown.
- Updated CNTLMClientAuth to use newer C++ style casts.
- Made the CNTLMClientAuth::NTLMAuthenticate function "exception"
safe, that is derived classes are free to throw exceptions in their implementations
of NTLMAuthPhase1, NTLMAuthPhase2 or NTLMAuthPhase3 and the CNTLMClientAuth
class will properly clean up its resources. This is achieved by making the CredHandle
and SecHandle values member variables of the class.
- Replaced all calls to ZeroMemory with memset.
- Now the public NTLMAuthenticate function allows you to pass a user name
and password pair to do NTLM authentication using a specified account instead
of the credentials of the current user. If you leave these values as NULL,
then you will get the old behaviour which is to use the current user credentials.
Thanks to Wouter Demuynck for this very nice addition.
V2.62 (29 June 2006)
- Updated the documentation to use the same style as the web site.
- Combined the functionality of the _PJNNTLMCLIENTAUTH_DATA class into the
main CNTLMClientAuth class.
- Code now uses new C++ style casts rather than old style C casts where necessary.
- Integrated ThrowPJNSMTPException function into CPJNSMTPConnection class
and renamed to ThrowPJNSMTPException
- Combined the functionality of the _PJNSMTP_DATA class into the main CPJNSMTPConnection
class.
- Updated the code to clean compile on VC 2005
- Updated copyright details.
- Removed unnecessary checks for failure to allocate via new since in MFC
these will throw CMemoryExceptions!.
- Optimized CPJNSMTPException constructor code
9 December 2005
- Updated the usage section of the documentation on how to correctly exclude
the SSL functionality from the class. Thanks to Berni Slootbeek for prompting
this update.
- Updated the usage section of the documentation on the preferred way of formatting
CID tags for MHTML emails. Thanks to Asle Rokstad for prompting this update.
V2.61 (16 November 2005)
- Now includes full support for connecting via SSL. For example sending mail
thro Gmail using the server "smtp.gmail.com" on port 465. Thanks to
Vladimir Sukhoy for providing this very nice addition (using of course the author's
very own OpenSSL wrappers!).
V2.60 (7 October 2005)
- Fixed an issue where file attachments were incorrectly including a charset
value in their headers. Thanks to Asle Rokstad for reporting this issue.
V2.59 (2 October 2005)
- MXLookup functionality of the class can now be excluded via the preprocessor
define "CPJNSMTP_NOMXLOOKUP". Thanks to Thiago Luiz for prompting
this update.
- Sample app now does not bother asking for username and password if authentication
type is NTLM. Thanks to Emir Kapic for spotting this issue.
- Documentation has been updated to refer to issues with NTLM Authentication
and SSPI. Thanks to Emir Kapic for prompting this update.
- Fixed an update error done for the previous version which incorrectly supported
the additional 251 command for the "MAIL" command instead of more
correctly the "RCPT" command. Thanks to Jian Peng for reporting this
issue.
V2.58 (29 September 2005)
- Removed linkage to secur32.lib as all SSPI functions are now constructed
at runtime using GetProcAddress. Thanks to Emir Kapic for this update.
- MD5 Format method now allows you to specify an uppercase or lower case string
for the hash. This is necessary since the CRAM-MD5 authentication mechanism
requires a lowercase MD5 hash. Thanks to Jian Peng for reporting this issue.
- 250 or 251 is now considered a successful response to the RCPT command.
Thanks to Jian Peng for reporting this issue.
- Fixed potential memory leaks in the implementation of NTLM authentication
as the code was throwing exceptions which the authentication code was not expected
to handle.
V2.57 (7 September 2005)
- Fixed another single dot issue, this time where the body is composed of
just a single dot. Thanks to Raimund Mettendorf for reporting this issue.
- Fixed a typo in the accessor function CPJNSMTPConnection::GetBoundAddress
which was incorrectly called CPJNSMTPConnection::SetBoundAddress. Thanks to
Pavel Kolar for reporting this.
V2.56 (5 September 2005)
- Fixed an issue in MXLookup method where memory was not being freed correctly
in the call to DnsRecordListFree. Thanks to Raimund Mettendorf for reporting
this bug.
- Fixed an issue where lines which had a single dot i.e. "." did
not get mailed correctly. Thanks to Raimund Mettendorf for reporting this issue.
- Removed the call to FixSingleDot from SetText method as it is done at runtime
as the email as being sent. This was causing problems for fixing up the dot
issue when MIME encoded messages were being sent.
- Function pointer to CompleteAuthToken is now constructed at runtime. This
means that NTLM client authentication will work correctly on Win9x as used by
the class CPJNSMTPConnection and any other class instead of bringing up a "Failed
to load due to missing export..." message from the Windows loader. If you
want to remove the NTLM support from CPJNSMTPConnection then you can continue
to use the CPJNSMTP_NONTLM preprocessor define. Thanks to "Lior" for
reporting this problem.
- Fixed an issue where the FixSingleDot function was being called when saving
a message to disk. This was incorrect and it should only be done when actually
sending an SMTP email.
V2.55 (14 August 2005)
- Minor update to include comments next to various locations in the code to
inform users what to do if they get compile errors as a result of compiling
the code without the Platform SDK being installed. Thanks to Gudjon Adalsteinsson
for prompting this update.
- Fixed an issue when the code calls the function DnsQuery when the code is
compiled for UNICODE. This was the result of a documentation error in the Platform
SDK which incorrectly says that DnsQuery_W takes a ASCII string when in actual
fact it takes a UNICODE string. Thanks to John Oustalet III for reporting this
issue.
V2.54 (24 July 2005)
- Now includes support for parsing "(...)" comments in addresses.
Thanks to Alexey Kuznetsov for this nice addition.
- Fixed an issue where the mail header could contain a "Content-Transfer-Encoding"
header. This header should only be applied to headers of MIME body parts rather
than the mail header itself. Thanks to Jeroen van der Laarse, Terence Dwyer
and Bostjan Erzen for reporting this issue and the required fix.
- Now calling both AddTextBody and AddHTMLBody both set the root body part
MIME type to multipart/mixed. Previously the code comments said one thing and
did another (set it to "multipart/related"). Thanks to Bostjan Erzen
for reporting this issue.
18 May 2005
- Fixed a compiler warning in the CPJNMD5Hash class when compiled using Visual
Studio .NET 2003. Thanks to Alexey Kuznetsov for reporting this issue.
V2.53 (3 May 2005)
- Updated the usage section to describe the need to have the Platform SDK
installed and configured.
- Fixed a number of warnings when the code is compiled in Visual Studio .NET
2003. Thanks to Nigel Delaforce for reporting these issues.
V2.52 (1 May 2005)
- Now uses the author's CWSocket sockets wrapper class.
- Added support for connecting via Socks4, Socks5 and HTTP proxies
- The last parameter to Connect has now been removed and is configured via
an accessor / mutator pair Get/SetBoundAddress.
- CSMTPException class is now called CPJNSMTPException.
- Class now uses the Base64 class as provided with CWSocket. This means that
the modules Base64Coder.cpp/h are no longer distributed or required and should
be removed from any projects which use the updated SMTP classes.
- Fixed a bug in SaveToDisk method whereby existing files were not being truncated
prior to saving the email message.
- All calls to allocate heap memory now generate a CPJNSMTPException if the
allocation fails.
- Addition of a MXLookupAvailable() function so that client code can know
a priori if DNS MX lookups are supported.
- Sample app now allows you to use the MXLookup method to determine the mail
server to use based on the first email address you provide in the To field.
V2.51 (23 April 2005)
- The code now uses a MS Crypto API implementation of the MD5 HMAC algorithm
instead of custom code based on the RSA MD5 code. This means that there is no
need for the RSA MD5.cpp, MD5.h and glob-md5.h to be included in client applications.
In addition the build configurations for excluding the RSA MD5 code has been
removed from the sample app. The new classes to perform the MD5 hashing are
contained in PJNMD5.h and are generic enough to be included in client applications
in their own right.
V2.50 (18 April 2005)
- Addition of a simple IsConnected() function inline with the author's
CPop3Connection class. Thanks to Alexey Kuznetsov for prompting this addition.
- Addition of a MXLookup function which provides for convenient DNS lookups
of MX records (the IP addresses of SMTP mail servers for a specific host domain).
Internally this new function uses the new DNS functions which are provided with
Windows 2000 or later. To ensure that the code continues to work correctly on
earlier versions of Windows, the function pointers for the required functions
are constructed at runtime using GetProcAddress. You can use this function to
discover the IP address of the mail servers responsible for a specific domain.
This allows you to deliver email directly to a domain rather than through a
third party mail server. Thanks to Hans Dietrich for suggesting this nice addition.
V2.49 (26 March 2005)
- Fixed compile problems with the code when the Force Conformance In For Loop
Scope compile setting is used in Visual Studio .NET 2003. Thanks to Alexey Kuznetsov
for reporting this problem.
- Fixed compile problems when the code is compiled using the Detect 64-bit
Portability Issues setting in Visual Studio .NET 2003.
V2.48 (7 March 2005)
- Addition of PJNSMTP_EXT_CLASS define to the classes to allow the classes
to be easily incorporated into extension DLLs. Thanks to Arnaud Faucher for
suggesting this addition.
- Now support NTLM authentication. Thanks to Arnaud Faucher for this nice
addition. NTLM Authentication is provided by a new reusable class called "CNTLMClientAuth"
in PJNNTLMAuth.cpp/h".
- Fixed a bug in the sample app in the persistence of the Authentication setting.
Thanks to Arnaud Faucher for reporting this issue.
19 February 2005
- Updated the usage section of the documentation to describe what is required
to integrate the code into your applications. Thanks to Matthew Tompkins for
prompting this update.
V2.47 (24 January 2005)
- All classes now uses exceptions to indicate errors. This means the whole
area of handling errors in the code a whole lot simpler. For example the OnError
mechanism is gone along with all the string literals in the code. The actual
code itself is a whole lot simpler also. You should carefully review your code
as a lot of the return values from methods (especially CPJNSMTPConnection) are
now void and will throw CSMTPException's. Thanks to Mark Smith for prompting
this update.
- General tidy up of the code following the testing of the new exception based
code.
V2.46 (23 December 2004)
- "Name" field in Content-Type headers is now quoted just like the
filename field. Thanks to Mark Smith for reporting this issue in conjunction
with the mail client Eudora.
V2.45 (30 September 2004)
- Fixed a parsing issue in CPJNSMTPConnection::ReadResponse when multi line
responses are read in as multiple packets. Thanks to Mark Smith for reporting
this problem.
- Reworked the code which supports the various authentication mechanisms to
support the correct terms. What was called "AUTH LOGIN PLAIN" support
now more correctly uses the term "AUTH PLAIN". The names of the functions
and enums have now also been reworked.
- Did a review of the sample app code provided with the class so that the
name of the modules, projects, exe etc is now "PJNSMTPApp". Also reworked
the name of some helper classes as well as the module name which supports the
main class.
- Reworked CPJNSMTPConnection::AuthLoginPlain (now called AuthPlain) to correctly
handle the case where an invalid response is received when expecting the username:
response. Thanks to Mark Smith for reporting this problem.
V2.44 (7 June 2004)
- Fixed a potential buffer overflow issue in CSMTPConnection::ReadResponse
when certain multi line responses are received
V2.43 (5 June 2004)
- Fixed a bug in CSMTPConnection::ReadResponse, where the wrong parameters
were being null terminated. Thanks to "caowen" for this update.
- Updated the CSMTPConnection::ReadResponse function to handle multiline responses
in all cases. Thanks to Thomas Liebethal for reporting this issue.
V2.42 (13 March 2004)
- Fixed a problem where the CSMTPBodyPart::m_dwMaxAttachmentSize value was
not being copied in the CSMTPBodyPart::operator= method. Thanks to Gerald Egert
for reporting this problem and the fix.
V2.41 (4 March 2004)
- To avoid conflicts with the ATL Server class of the same name "CPJNSMTPConnection",
the class is now called "CPJNSMTPConnection". To provide for easy
upgrading of code, "CSMTPConnection" is now defined to be CPJSMTPConnection"
if the code detects that the ATL Server SMTP class is not included. Thanks to
Ken Jones for reporting this issue.
V2.40 (18 February 2004)
- You can now optionally set the priority of an email thro the variable CPJNSMTPMessage::m_Priority.
Thanks to Edward Livingston for suggesting this addition.
V2.39 (7 February 2004)
- Fixed a bug in CSMTPBodyPart::SetText where the code would enter an endless
loop in the Replace function. It has now been replaced with CString::Replace.
This now means that the class will not now compile on VC 5. Thanks to Johannes
Philipp Grohs for reporting this problem.
- Fixed a number of warnings when the code is compiled with VC.Net 2003. Thanks
to Edward Livingston for reporting this issue.
V2.38 (31 January 2004)
- Fixed a bug in CSMTPBodyPart::GetBody where the size of the body part was
incorrectly calculating the size if the encoded size was an exact multiple of
76. Thanks to Kurt Emanuelson and Enea Mansutti for reporting this problem.
V2.37 (11 December 2003)
- Fixed an unreferrenced variable in CPJNSMTPConnection::OnError as reported
by VC.Net 2003
- DEBUG_NEW macro is now only used on VC 6 and not on VC 7 or VC 7.1. This
avoids a problem on these compilers where a conflict exists between it and the
STL header files. Thanks to Alex Evans for reporting this problem.
V2.36 (3 December 2003)
- Made code which checks the Login responses which contain "Username"
and "Password" case insensitive. Thanks to Zhang xiao Pan for reporting
this problem.
V2.35 (3 November 2003)
- Simplified the code in CPJNSMTPConnection::ReadResponse. Thanks to Clarke
Brunt for reporting this issue.
V2.34 (15 October 2003)
- Reworked the CPJNSMTPConnection::ReadResponse method to use the timeout
provided by IsReadable rather than calling sleep. Thanks to Clarke Brunt for
reporting this issue.
19 August 2003
- Updated the sample app to avoid a memory leak. It turns out that it was
to do with the ordering of <string> in the pre compiled header. I was
never too fond of STL and this has confirmed my prejudices. Thanks to
Damian Willis for reporting this problem.
V2.33 (18 August 2003)
- Modified the return value from the ConnectToInternet method. Instead of
it being a boolean, it is now an enum. This allows client code to differentiate
between two conditions that it couldn't previously, namely when an internet
connection already existed or if a new connection (presumably a dial-up connection
was made). This allows client code to then disconnect if a new connection was
required. Thanks to Pete Arends for this nice addition.
V2.32 (12 May 2003)
- Fixed a bug where the X-Mailer header was being sent incorrectly. Thanks
to Paolo Vernazza for reporting this problem.
- Addition of X-Mailer header is now optional. In addition sample app now
does not send the X-Mailer header.
- The sample app now does not send the Reply-To header.
V2.31 (5 May 2003)
- Reworked the way UTF8 encoding is now done. What you should do if you want
to use UTF-8 encoding is set the charset "UTF-8" and use either
QP or base 64 encoding.
- Reworked the automatic encoding of the subject line to use the settings
as taken from the root SMTP body part
- Only the correct headers according to the MIME RFC are now encoded.
- QP encoding is the encoding mechanism now always used for headers.
- Headers are now only encoded if required to be encoded.
V2.30 (4 May 2003)
- Fixed an issue where the class doesn't convert the mail body and subject
to the wanted encoding but rather changes the encoding of the email in the email
header. Since the issue of supporting several languages is a complicated one
I've decided that we could settle for sending all CPJNSMTPConnection emails
in UTF-8. I've added some conversion functions to the class that - at this
point - always converts the body and subject of the email to UTF-8. A big thanks
to Itamar Kerbel for this nice addition.
- Moved code and sample app to VC 6.
V2.29 (19 April 2003)
- Fixed a bug in the CSMTPAddress constructor where I was mixing up the friendly
name in the "<>" separators, when it should have been the email
address.
V2.28 (17 April 2003)
- Enhanced the CSMTPAddress constructor to parse out the email address and
friendly name rather than assume it is an email address.
- Reworked the syntax of the CPJNSMTPMessage::ParseMultipleRecipients method.
Also now internally this function uses the new CSMTPAddress constructor.
V2.27 (13 April 2003)
- Fixed a bug in the handling of EHLO responses. Thanks to "Senior"
for the bug report and the fix.
V2.26 (19 March 2003)
- Addition of copy constructors and operator= to CPJNSMTPMessage class. Thanks
to Alexey Vasilyev for this suggestion.
9 February 2003
- Updated the sample app to display a simple progress dialog when you send
a message from disk (not using the "Send Direct") option. This provides
a sample of how you can implement a cancellable send of a message with progress
support. Thanks to "nabocorp" for suggesting this addition to the
sample.
V2.25 (7 February 2003)
- Addition of a "BOOL bGracefully" argument to Disconnect so that
when an application cancels the sending of a message, you can pass FALSE and
close the socket without properly terminating the SMTP conversation. Thanks
to "nabocorp" for this nice addition.
- Did a spell check on the documentation <g>.
V2.24 (11 December 2002)
- Review all TRACE statements for correctness
- Provided a virtual OnError method which gets called with error information.
V2.23 (4 October 2002)
- Fixed an issue where the header / body separator was not being sent correctly
for mails with attachments or when the message is MIME encoded. Thanks to Serhiy
Pavlov for reporting this problem.
- Fixed a bug in QuotedPrintableEncode and HeaderEncode which was causing
the errors. Thanks to Antonio Maiorano for reporting this problem.
- Fixed an issue with an additional line separator being sent between the
header and body of emails. This was only evident in mail clients if a non mime
email without attachments was sent.
V2.22 (3 October 2002)
- Quoted printable encoding didn't work properly in UNICODE. (invalid
conversion from TCHAR to BYTE). Thanks to Serhiy Pavlov for reporting this problem.
- Subject encoding didn't work properly in UNICODE. (invalid conversion
from TCHAR to BYTE). Thanks to Serhiy Pavlov for reporting this problem.
- It didn't insert "charset" tag into root header for plain
text messages (now it includes "charset" into plain text messages
too). Thanks to Serhiy Pavlov for reporting this problem.
V2.21 (20 September 2002)
- Fixed a problem where the code "Coder.EncodedMessage" was not
being converted from an ASCII string to a UNICODE string in calls to CString::Format.
This was occurring when sending the username and password for "AUTH LOGIN"
support in addition to sending the "username digest" for "AUTH
CRAM-MD5" support. Thanks to Serhiy Pavlov for reporting this problem.
- Removed a number of calls to CString::Format and instead replaced with string
literal CString constructors instead.
V2.20 (10 August 2002)
- Fixed a number of uncaught file exceptions in CSMTPBodyPart::GetBody, CPJNSMTPMessage::SaveToDisk
and CPJNSMTPConnection::SendMessage. Thanks to John Allan Miller for reporting
this problem.
- The CPJNSMTPConnection::SendMessage version of the method which sends a
file directly from disk, now fails if the file is empty.
- Improved the sample app by displaying a wait cursor while a message from
file is being sent.
- Improved the sample app by warning the user if mail settings are missing
and then bringing up the configuration dialog.
V2.19 (29 July 2002)
- Fixed an access violation in CSMTPBodyPart::QuotedPrintableEncode. Thanks
to Fergus Gallagher for spotting this problem.
- Fixed a problem where in very rare cases, the QuotedPrintableEncode function
produces a single dot in a line, when inserting the "=" to avoid the
mail server's maxline limit. I inserted a call to FixSingleDot after calling
the QuotedPrintableEncode function in GetBody. Thanks to Andreas Kappler for
spotting this problem.
- Fixed an issue in CSMTPBodyPart::GetHeader which ensures all mail clients
can correctly handle body parts and attachments which have a filename with spaces
in it. Thanks to Andreas Kappler for spotting this problem.
- QP encoding is now only used when you specify MIME. This fixes a bug as
reported by David Terracino.
- Removed now unused "API Reference" link in HTML file supporting
the code.
13 January 2002
- Minor update to the sample app to fix a bug in browsing for attachments,
Core classes not changed.
V2.18 (11 January 2002)
- Now includes a method to send a message directly from memory. Thanks to
Tom Allebrandi for this suggestion.
- Change function name "IsReadible" to be "IsReadable".
I was never very good at English!.
- Fixed a bug in CSMTPBodyPart::QuotedPrintableEncode. If a line was exactly
76 characters long plus \r\n it produced an invalid soft linebreak of "\r=\r\n\n".
Thanks to Gerald Egert for spotting this problem.
V2.17 (12 October 2001)
- Fixed a problem where GetBody was reporting the size as 1 bigger than it
should have been. Thanks to "c f" for spotting this problem.
- Fixed a bug in the TRACE statements when a socket connection cannot be made.
- The sample app now displays a filter of "All Files" when selecting
attachments to send
- Fixed a problem sending 0 byte attachments. Thanks to Deng Tao for spotting
this problem.
V2.16 (29 September 2001)
- Fixed a bug in ReadResponse which occurred when you disconnected via Dial-Up
Networking while a connection was active. This was originally spotted in my
POP3 class.
- Fixed a problem in CSMTPBodyPart::GetHeader which was always including the "quoted-printable"
even when
m_bQuotedPrintable for that body part was FALSE. Thanks to "jason"
for spotting this.
V2.15 (13 August 2001)
- Fixed a bug in QuotedPrintableEncode which was wrapping encoding characters
across multiple lines. Thanks to Roy He for spotting this.
- Provided a "SendMessage" method which sends a email directly from
disk. This allows you to construct your own emails and the use the class just
to do the sending. This function also has the advantage that it efficiently
uses memory and reports progress.
- Provided support for progress notification and cancelling via the "OnSendProgress"
virtual method.
V2.14 (15 July 2001)
- Improved the error handling in the function CPJNSMTPMessage::AddMultipleAttachments.
In addition the return value has been changed from BOOL to int.
V2.13 (1 July 2001)
- Modified QuotedPrintableEncode to prevent the code to enter in an infinite
loop due to a long word i.e. bigger than SMTP_MAXLINE, in this case, the word
is broken. Thanks to Manuel Gustavo Saraiva for this fix.
- Provided a new protected variable in CSMTPBodyPart called m_bQuotedPrintable
to bypass the QuotedPrintableEncode function in cases that we don't want
that kind of correction. Again thanks to Manuel Gustavo Saraiva for this fix.
V2.12 (25 June 2001)
- Code now links in Winsock and RPCRT40 automatically. This avoids client
code having to specify it in their linker settings. Thanks to Malte and Phillip
for spotting this issue.
- Updated sample code in documentation. Thanks to Phillip for spotting this.
- Improved the code in CSMTPBodyPart::SetText to ensure lines are correctly
wrapped. Thanks to Thomas Moser for this fix.
V2.11 (17 June 2001)
- Fixed a bug in CPJNSMTPMessage::HeaderEncode where spaces were not being
interpreted correctly. Thanks to Jim Alberico for spotting this.
- Fixed 2 issues with ReadResponse both having to do with multi-line responses.
Thanks to Chris Hanson for this update.
V2.1 (14 May 2001)
- Charset now defaults to ISO 8859-1 instead of us-ascii
- Removed a number of unreferenced variables from the sample app.
- Headers are now encoded if they contain non ascii characters.
- Fixed a bug in getLine, Thanks to Lev Evert for spotting this one.
- Made the charset value a member of the message class instead of the connection
class
- Sample app now fully supports specifying the charset of the message
- Added a AddMultipleAttachments method to CPJNSMTPMessage
- Attachments can now be copied to each other via new methods in CSMTPAttachment
- Message class now contains copies of the attachments instead of pointers
to them
- Sample app now allows multiple attachments to be added
- Removed an unnecessary assert in QuotedPrintableEncode
- Added a Mime flag to the CPJNSMTPMessage class which allows you to decide
whether or not a message should be sent as MIME. Note that if you have attachments,
then mime is assumed.
- CSMTPAttachment class has now become CSMTPBodyPart in anticipation of full
support for MIME and MHTML email support
- Updated copyright message in source code and documentation
- Fixed a bug in GetHeader related to _tsetlocale usage. Thanks to Sean McKinnon
for spotting this problem.
- Fixed a bug in SendLines when sending small attachments. Thanks to Deng
Tao for spotting this problem.
- Removed the need for SendLines function entirely.
- Now fully supports HTML email (aka MHTML)
V2.04 (28 December 2000)
- Removed an unused variable from ConnectESMTP.
- Allowed the hostname as sent in the HELO command to be specified at run
time in addition to using the hostname of the client machine
- Fixed a problem where high ASCII characters were not being properly encoded
in the quoted-printable version of the body sent.
- Added support for user definable charset's for the message body.
- Mime boundaries are now always sent irrespective of whether attachments
are included or not. This is required as the body is using quoted-printable.
- Fixed a bug in sendLines which was causing small message bodies to be sent
incorrectly
- Now fully supports custom headers in the SMTP message
- Fixed a copy and paste bug where the default port for the SMTP socket class
was 110.
- You can now specify the address on which the socket is bound. This enables
the programmer to decide on which NIC data should be sent from. This is especially
useful on a machine with multiple IP addresses.
- Addition of functions in the SMTP connection class to auto dial and auto
disconnect to the Internet if you so desire.
- Sample app has been improved to allow Auto Dial and binding to IP addresses
to be configured.
- Thanks go to Yaroslav Liapkov, Josef Hampl, Duncan Strand, Fritz Roland "Nick"
Bjorklund, Lev Elbert and Perry Rapp for finding these problems and/or suggesting
the improvements.
V2.03 (5 September 2000)
- Added a CSMTP_NORSA preprocessor macro to allow the CPJNSMTPConnection code
to be compiled without the dependence on the RSA code.
V2.02 (30 July 2000)
- Fixed a bug in AuthLogin which was transmitting the username and password
with an extra "=" which was causing the login to failure. Thanks to
Victor Vogelpoel for finding this.
V2.01 (10 July 2000)
- Fixed a problem with sending attachments > 1K in size.
- Changed the parameters to CPJNSMTPConnection::Connect
V2.0 (21 June 2000)
- Now includes a number of files missing from the zip file.
- Updated the version number to v2 to reflect the major changes which occurred
in v1.41
V1.41 (20 June 2000)
- Removed the base64 encoder from this file
- Added the base64 encoder/decoder implementation in a separate file. This
was done because base64 decoding was not part of the previous implementation
- Added support for ESMTP connection. The class now attempts to authenticate
the user on the ESMTP server using the username and passwords supplied. For
this connect now takes the username and passwords as parameters. These can be
null in which case ESMTP authentication is not attempted
- This class can now handle AUTH LOGIN and AUTH LOGIN PLAIN authentication
schemes
- Added the files md5.* containing the MD5 digest generation code after modifications
so that it compiles with VC++ 6
- Added support for CRAM-MD5 login.
- Please note that all the support for SMTP authentication was added by Puneet
Pawaia to which I am gratefully appreciated for all the hard work put in.
V1.40 (7 May 2000)
- Addition of some ASSERTs in CSMTPSocket::Connect.
V1.39 (28 March 2000)
- Set the release mode timeout to be 10 seconds. 2 seconds was causing problems
for slow dial up networking connections.
V1.38 (26 March 2000)
- Updated the sample app provided with the code to be a mini mail client.
This should now also give a better idea of what the code can be used for.
V1.37 (19 March 2000)
- Fixed a problem in GetHeader on Non-English Windows machines
- Now ships with a VC 5 workspace. I accidentally shipped a VC 6 version in
one of the previous versions of the code.
- Fixed a number of UNICODE problems
- Updated the sample app to deliberately assert before connecting to the author's
SMTP server.
V1.36 (16 February 2000)
- Fixed another compiler problem when compiled with VC 6.
V1.35 (5 October 1999)
- Fixed 2 level 4 warnings when compiled using VC 6.
V1.34 (10 September 1999)
- Improved CPJNSMTPMessage::GetHeader to include mime field even when no attachments
are included.
V1.33 (14 May 1999)
- Updated documentation to refer to RFC 822.
- Fixed a bug with the way the code generates time zone fields in the Date
headers. Thanks to Randy A. Scott for reporting this bug.
V1.32 (25 March 1999)
- Now sleeps for 250 ms instead of yielding the time slice. This helps reduce
CPU usage when waiting for data to arrive in the socket.
V1.31 (22 February 1999)
- Added a Get and SetTitle method which allows a files attachment title to
be different that the original filename.
- Updated sample app to include a more descriptive subject line.
- Default timeout for the code when a debug build is built has now been set
to 60 seconds.
- Improved the reading of responses back from the server by implementing a
growable receive buffer.
- Updated instructions on how the relevant RFC documents can be retrieved.
V1.3 (18 January 1999)
- Full support has now been added for CC (Carbon Copy) & BCC (Blind Carbon
Copy).
V1.21 (12 September 1998)
- Removed a couple of unreferenced variable compiler warnings discovered when
the class was compiled on Visual C++ 6.0.
- Fixed a major bug which was causing an ASSERT when the CSMTPAttachment destructor
was being called in the InitInstance of the sample app. This was inadvertently
introduced for the 1.2 release. The fix is to revert fix 2) as done for v1.2.
This new fix will also help to reduce the number of attachment images kept in
memory at one time.
- Fixed a few errors in this help file.
V1.2 (11 August 1998)
- VC 5 project file is now provided instead of VC 4.x
- Attachment array which the message class contains now uses references instead
of pointers.
- Now uses Sleep(0) to yield our time slice instead of Sleep(100), this is
the preferred way of writing polling style code in Win32 without severely impacting
performance.
- All trace statements now display the value as returned from GetLastError
- A number of extra asserts have been added
- AddMultipleRecipients has been added which supports added a number of recipients
at one time from a single string
- Extra trace statements have been added to help in debugging
- A number of updates to the documentation.
V1.12 (27 June 1998)
- The case where a line begins with a "." but contains other text
is now also catered for. See RFC 821, Section 4.5.2 for further details.
- m_sBody in CPJNSMTPMessage has now been made protected. Client applications
now should call AddBody instead. This ensures that FixSingleDot is only called
once even if the same message is sent a number of times.
- Fixed a number of problems with how the MIME boundaries were defined and
sent.
- Got rid of an unreferenced formal parameter compiler warning when doing
a release build.
V1.11 (18 June 1998)
- Fixed a memory overwrite problem which was occurring with the buffer used
for encoding base64 attachments.
V1.1 (17 June 1998)
- Fixed the case where a single dot occurs on its own in the body of a message
- Classes now supports an optional "Reply-To" Header Field
- Classes now fully supports file attachments
- Some rework on the contents of the help file
V1.0 (26 May 1998)
Contacting the Author
PJ Naughter
Email<EMAIL_ADDRESS>Web:
http://www.naughter.com
18 December 2017


TABLE OF CONTENTS
A. GS1 Related Indian Society 1. Liberalization’s impact on gender discrimination B. GS2 Related Polity 1. Y.C. Modi, CBI special director case, named NIA chief 2. Rethinking police reform C. GS3 Related Economy 1. Shell shock: Govt. ‘names and shames’ directors Environmental Science And Ecology 1. Giant sea snail plan to rescue Barrier Reef D. GS4 Related E. Prelims Fact Articles and Constitutional Provisions in News 1. Article 191. Disqualifications for membership F. UPSC Prelims Practice Questions G. UPSC Mains Practice Questions
1. Liberalization’s impact on gender discrimination
Context:
- Conventional wisdom suggests that economic reforms succeeding liberalization policy of government in early 1990s should have reduced gender discrimination—but that hasn’t really been the case.
- India’s gender balance in entrepreneurship and jobs remains among the lowest in the world.
- Globalization and trade policy have made a limited contribution towards India’s convergence in gender segmentation.
Liberalization and gender Discrimination:
- Increased market competition, forces firms to eliminate inefficient discriminatory practices, including gender discrimination
- Market competition works in favour of women, as women are more competitive, and offer cheaper and more flexible labour vis-à-vis men.
Present trends:
- The share of females in manufacturing employment has barely increased over the last two decades. Female activity is largely concentrated in the unorganized sector.
- Women entrepreneurs are more dominant in industries that pay lower average wages.
- Despite many competitive reforms that India has undertaken, this pattern of gender-based segmentation has been accentuated over the years.
Manufacturing Sector
- The female ownership shares are highest and typically exceed 50% in industries related to chemicals and chemical products, tobacco products, and paper and paper products.
- At the opposite end, female ownership shares are 2% or less in industries related to computers, motor vehicles, fabricated metal products, and machinery and equipment.
Service sector
- Among service industries, female ownership shares exceed 30% in industries related to sanitation and education. Industries related to research and development, water transport, and land transport have the lowest female ownership rates, at 1% or less.
- The female ownership rates in major cities tend to be higher than overall state averages.
- The states with the highest female service sector ownership rates are Kerala, Tamil Nadu, and Andhra Pradesh, with average female ownership shares exceeding 12%.
- The lowest female ownership rates are in Rajasthan, Bihar, Odisha, and Uttar Pradesh, each with 6% or less. It is surprising that the nation’s capital, Delhi, has the lowest share of female-owned establishments in manufacturing. Its position in the services sector is only slightly above the national average.
Factors Affecting Female Entry into various Industries
- Empirical results suggest that a district/industry with more incumbent female employment has a greater female entry share. Among district-level traits, a higher female-to-male ratio, an age profile emphasizing working age population, and better quality infrastructure appear important.
- Inadequate infrastructure also affects women more than men, because women are often responsible for a larger share of, and often more time-consuming, household activities.
- In particular, transport infrastructure and paved roads within villages play an important role. Travel in India can be restrictive and unpredictable, and women face greater constraints in geographic mobility imposed by safety concerns and social norms.
- Better electricity and water access may reduce the burden of women in providing essential household inputs for their families, and allow for more time to be directed toward entrepreneurial activities.
Way forward:
- India’s 73rd Constitutional Amendment Act, passed in 1992, instituted one-third seat reservations for women in local governance bodies. The political empowerment of women had huge beneficial effects. The political reservation for women has gained India global recognition.
- India’s economic liberalization and increased market competition has not eliminated gender segmentation. However, improved physical and human infrastructure, and domestic pro-competitive reforms have reduced gender segmentation.
- Gender will play a bigger and more strategic role in India’s future growth.
- This growth will come in many forms: increased female labour force participation, improvements in productivity, elimination of gender discrimination in access to bank loans, and increased voice and political representation.
- Simply put, empowering half of the potential workforce has significant economic benefits beyond promoting gender equality.
1. Y.C. Modi, CBI special director case, named NIA chief
In news:
- The appointments committee of the cabinet (ACC) named senior IPS officer Y.C. Modi to head the National Investigation Agency (NIA), according to an order issued by the Department of Personnel and Training (DoPT).
- Modi, a 1984 batch IPS officer of the Assam-Meghalaya cadre, was part of the Supreme Court-appointed special investigation team that probed the 2002 Gujarat riot cases.
- Modi currently works as special director in the Central Bureau of Investigation (CBI).
Basic Information:
National Investigation Agency:
- National Investigation Agency (NIA) is a central agency established by the Indian Government to combat terror in India.
- It acts as the Central Counter Terrorism Law Enforcement Agency.
- The agency is empowered to deal with terror related crimes across states without special permission from the states.
- The Agency came into existence with the enactment of the National Investigation Agency Act 2008 by the Parliament of India on 31 December 2008.
- NIA was created after the 2008 Mumbai terror attacks as need for a central agency to combat terrorism was realised.
Jurisdiction:
- The Agency has been empowered to conduct investigation and prosecution of offences under the Acts specified in the Schedule of the NIA Act.
- A State Government may request the Central Government to hand over the investigation of a case to the NIA, provided the case has been registered for the offenses as contained in the schedule to the NIA Act.
Central Government can also order NIA to take over investigation of any scheduled offense anywhere in the India. Officers of the NIA who are drawn from the Indian Revenue Service, Indian Police Service, state police, Income Tax as well as officers from the Central Armed Police Forces, have all powers, privileges and liabilities which the police officers have in connection with investigation of any offence.
Context:
- State police forces in India are among the least trusted public institutions
- “Can anything be done?”
Background
- According to the Bureau of Police Research and Development (BPRD), there are 15,268 police stations in India
- These stations are organized under various administrative units like circles, subdivisions, districts, ranges and zones
- The median ratio of police officers to constabulary is 5%
Key stats:
- There are a total of about 1.8 million police personnel employed by Indian state police organizations today and there are also 300,000 vacancies
- This results in a median 200 policemen for every 100,000 people, though it ranges widely from 76 in Bihar to 700 in Delhi
Solutions:
- Dealing with 21st century challenges with the (currently applicable) Police Act of 1861 creates lots of issues
- The politicization of the police is a tough problem to solve in an environment in which money, votes, and instruments of intimidation (misuse of the police) mix
- According to a Takshashila Institution survey of public trust, state police organizations rank last among government organizations and agencies
- Numerous committees and commissions have opined on the issue of police reform
- Most of them have approached the problem from a quantity, capacity, capability, training, compensation and benefits point of view
- The solutions may generally be grouped into the idea of “if you make the policeman’s conditions better, then everything will improve”
Second Administrative Reforms Commission (ARC) and police reforms:
- The ARC recommended that the investigative functions of police be separated from the day-to-day law and order functions
- And the superintendence of the government over police be restricted in such a manner that the force retains operational autonomy
- It suggested a State Accountability Commission made up of five members of government, including the home minister and chief secretary and five non-partisan eminent citizens
- The ARC recommendation resolved the politicization dilemma by delegating operational control to the force and democratizing governance to a commission
Way forward:
- Codifying checks and balances in respective police Acts will bring assurance against illegal orders by the political establishment to the police
- Currently, politicians use the power of the police for their purposes, but sidestep any responsibility for their failures
- Only by giving full accountability to the politicians can society hold the politicians responsible for their actions
- Only when full political accountability joints with the betterment in capacity, capability and equipment can we begin true police reform
1. Shell shock: Govt. ‘names and shames’ directors
Context:
- Ministry of Corporate Affairs has identified 1.06 lakh directors of ‘shell companies’ for disqualification under the relevant provisions of the Companies Act, 2013.
- The move is part of actions to break the network of ‘shell companies’ and further the fight against black money/money laundering
In news:
- ‘Name and shame’ exercise: Ministry of Corporate Affairs (MoCA) has begun making public the lists of disqualified directors across the nation as well as those associated with struck-off companies.
- The disqualified in the lists are those who are, or had been a director, in a company that has not filed financial statements or annual returns for any continuous period of three financial years. Such directors will not be eligible for re-appointment as a director in that company or for appointment in other companies for five years from the date of non-compliance.
- Several Keralite businessmen, leading politicians, top civil servants and police officers figured in the lists.
Category: ENVIRONMENTAL SCIENCE AND ECOLOGY
1. Giant sea snail plan to rescue Barrier Reef
Context:
- Great Barrier Reef: Saving the corals.
In news:
- A giant starfish-eating snail (Pacific triton sea snail — also known as the giant triton) could be unleashed to help save the Great Barrier Reef.
- Predatory crown-of-thorns starfish, which munch coral, are naturally-occurring but have proliferated due to pollution and run-off at the struggling World Heritage-listed ecosystem
- A major study of the 2,300-km long reef’s health in 2012 shows coral cover halved over the past 27 years, with 42% of the damage attributed to the crown-of-thorns starfish.
- The snails, which can grow to half a metre, have a well developed sense of smell and can hunt their prey by scent alone.
Nothing here for Today!!!
Category: ARTICLES AND CONSTITUTIONAL PROVISIONS IN NEWS
Article 191. Disqualifications for membership
(1) A person shall be disqualified for being chosen as, and for being, a member of the Legislative Assembly or Legislative Council of a State
(a) if he holds any office of profit under the Government of India or the Government of any State specified in the First Schedule, other than an office declared by the Legislature of the State by law not to disqualify its holder;
(b) if he is of unsound mind and stands so declared by a competent court;
(c) if he is an undischarged insolvent;
(d) if he is not a citizen of India, or has voluntarily acquired the citizenship of a foreign State, or is under any acknowledgement of allegiance or adherence to a foreign State;
(e) if he is so disqualified by or under any law made by Parliament Explanation For the purposes of this clause, a person shall not be deemed to hold an office of profit under the Government of India or the Government of any State specified in the First Schedule by reason only that he is a Minister either for the Union or for such State
(2) A person shall be disqualified for being a member of the Legislative Assembly or Legislative Council of a State if he is so disqualified under the Tenth Schedule
F. Practice Questions for UPSC Prelims Exam
Question 1: Consider the following statements with reference to NIA
- The agency is empowered to deal with terror related crimes across states with permission from the states.
- NIA was created after the 2008 Mumbai terror attacks
Choose the correct statements from the options given below
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Question 2: A person shall be disqualified for being chosen as, and for being,
a member of the Legislative Assembly or Legislative Council of a State ,if
- He/she holds any office of profit under the Government of India or the Government of any State specified in the First Schedule, other than an office declared by the Legislature of the State by law not to disqualify its holder;
- He/she is of unsound mind and stands so declared by a competent court;
- He/ she is an undischarged insolvent;
- He/ she is not a citizen of India, or has voluntarily acquired the citizenship of a foreign State, or is under any acknowledgement of allegiance or adherence to a foreign State;
Identify the correct statements from the options given below
- A. 1and 3
- B. 1 and 4
- C. 1,2 and 4
- D. All are correct
Question 3. Buddhist Viharas are
- A monument to meditate and chant for the entire Sangha
- Permanent shelters or monasteries for dwelling and rest
- Divine extensions of stupas
- Sites containing relics of Buddha
Question 4. SATH - ‘Sustainable Action for Transforming Human capital’ initiative of
NITI Aayog focuses on
- Creating ‘role model’ states for health systems
- Revamping higher education
- Building workforce for the future in areas of cutting edge technology
- Eradicating manual scavenging
Question 5. The ‘Doctrine of Lapse’, in Modern Indian history, is associated with
- Lord Wellesley
- Lord William Bentick
- Lord Canning
- Lord Dalhousie
G. UPSC Mains Practice Questions
GS Paper I
-
“Conventional wisdom suggests that economic reforms succeeding liberalization policy of government in early 1990s should have reduced gender discrimination—but that hasn’t really been the case”. Discuss?
GS Paper II
-
“Codifying checks and balances in respective police Acts will bring assurance against illegal orders by the political establishment to the police”. Discuss.
Also, check previous Daily News Analysis
“Proper Current Affairs preparation is the key to success in the UPSC- Civil Services Examination. We have now launched a comprehensive ‘Current Affairs Webinar’. Limited seats available. Click here to Know More.”
Enroll for India’s Largest All-India Test Series


Register callback fn
for the command.
for chaining
Set an alias for the command.
Allow unknown options on the command line.
for chaining
Define argument syntax for the top-level command.
for chaining
Define a command, implemented using an action handler.
command name and arguments, args are <required>
or [optional]
and last may also be variadic...
configuration options
new command
Define a command, implemented in a separate executable file.
command name and arguments, args are <required>
or [optional]
and last may also be variadic...
description of executable command
configuration options
top level command for chaining more command definitions
Set the description to str
.
Output help information and exit.
You can pass in flags and a description to override the help flags and help description for your command.
Set the name of the command.
Get the name of the command.
Define option with flags
, description
and optional
coercion fn
.
The flags
string should contain both the short and long flags,
separated by comma, a pipe or space. The following are all valid
all will output this way when --help
is used.
"-p, --pepper" "-p|--pepper" "-p --pepper"
for chaining
Return an object containing options as key-value pairs
Output help information for this command.
When listener(s) are available for the helpLongFlag those callbacks are invoked.
Parse argv
, settings options and invoking commands when defined.
for chaining
Parse expected args
.
For example ["[type]"]
becomes [{ required: false, name: 'type' }]
.
for chaining
Parse options from argv
returning argv
void of these options.
Set or get the command usage.
Set the program version to str
.
This method auto-registers the "-V, --version" flag which will print the version number when passed.
You can optionally supply the flags and description to override the defaults.
Initialize a new
Command
.


Close Project
This sample runs a simple regression and displays a plot on the screen. It uses the mtcars dataset and allows the user to choose the Y and X variables for the regression.


passwd:
❌
🎲
💫
📋
Password Encryption
Encrypt
file:
💾⇨🧩
0%
Decrypt
file:
🧩⇨💾
0%
//==============================================
PubKey:
(none)
Encrypt
file:
💾⇨🧩
0%
Decrypt
file:
🧩⇨💾
0%


Triangle mesh geometry class. More...
#include <PxTriangleMeshGeometry.h>
Public Member Functions | |
| PX_INLINE | PxTriangleMeshGeometry () |
| Default constructor. More... | |
| PX_INLINE | PxTriangleMeshGeometry (PxTriangleMesh *mesh, const PxMeshScale &scaling=PxMeshScale(), PxMeshGeometryFlags flags=PxMeshGeometryFlags()) |
| Constructor. More... | |
| PX_INLINE bool | isValid () const |
| Returns true if the geometry is valid. More... | |
| Public Member Functions inherited from PxGeometry | |
| PX_CUDA_CALLABLE PX_FORCE_INLINE PxGeometryType::Enum | getType () const |
| Returns the type of the geometry. More... | |
Public Attributes | |
| PxMeshScale | scale |
| The scaling transformation. More... | |
| PxMeshGeometryFlags | meshFlags |
| Mesh flags. More... | |
| PxPadding< 3 > | paddingFromFlags |
| padding for mesh flags More... | |
| PxTriangleMesh * | triangleMesh |
| A reference to the mesh object. More... | |
Additional Inherited Members | |
| Protected Member Functions inherited from PxGeometry | |
| PX_CUDA_CALLABLE PX_FORCE_INLINE | PxGeometry (PxGeometryType::Enum type) |
| Protected Attributes inherited from PxGeometry | |
| PxGeometryType::Enum | mType |
Triangle mesh geometry class.
This class unifies a mesh object with a scaling transform, and lets the combined object be used anywhere a PxGeometry is needed.
The scaling is a transform along arbitrary axes contained in the scale object. The vertices of the mesh in geometry (or shape) space is the PxMeshScale::toMat33() transform, multiplied by the vertex space vertices in the PxConvexMesh object.
|
inline |
Default constructor.
Creates an empty object with a NULL mesh and identity scale.
|
inline |
Constructor.
| [in] | mesh | Mesh pointer. May be NULL, though this will not make the object valid for shape construction. |
| [in] | scaling | Scale factor. |
| [in] | flags | Mesh flags. \ |
| PxMeshGeometryFlags PxTriangleMeshGeometry::meshFlags |
Mesh flags.
| PxPadding<3> PxTriangleMeshGeometry::paddingFromFlags |
padding for mesh flags
| PxMeshScale PxTriangleMeshGeometry::scale |
The scaling transformation.
| PxTriangleMesh* PxTriangleMeshGeometry::triangleMesh |
A reference to the mesh object.


Academic talk setup - slides and virtual board
Last Monday, I had the pleasure of presenting our work with Benjamin Guedj, María Pérez-Ortiz, and John Shawe-Taylor, A PAC-Bayesian Perspective on ILE Structured Prediction to the Benjamin’s group at UCL. It was great to get impressions on the work from the other students and postdocs in the group.
Inspired by many researchers who have been honing the craft of Zoom presentations1, I spent a bit of time perfecting a setup that would allow me to give the talk using slides that I could annotate throughout the talk. I found that this would be closer to what the talk would have looked like, had we been all in a conference room in London.
The goal of the setup is to annotate PDF presentations while presenting using a graphical tablet. I had a beamer prepared but intended to add illustrations and diagrams during the presentation. It proved very useful when I was asked questions!
For future reference, this post documents the setup.
Ingredients: hardware & software
Hardware:
- Laptop: you’ll need access to a keyboard for to navigate efficiently during the presentation.
- Wacom tablet: One by Wacom Medium (60 euros). I chose a Wacom (over a cheaper knock-off) because I had found the Ubuntu drivers ahead of time!
Software
The software linked here is on Ubuntu 18.04, but everything should work on other platforms.
- Wacom drivers2
Zoom
for the meetingXournal++
for presenting and annotating.
In a nutshell
At a high-level the setup is as follows:
Xournal++
inPresentation mode
.Zoom
, sharing the portion of the screen that corresponds to the slides inXournal++
.
During the presentation, I used Xournal++
keyboard shortcuts to avoid switching between the mouse and the stylus (see below).
In this rest of this article, I’ll focus on setting up Xournal++
for presenting and annotating.
Xournal++: introduction
From the Xournal++
website:
Xournal++
is an cross-platform, open source, hand note-taking software with the target of flexibility, functionality, and speed.
It has a rich set of features – in particular it can be extended through Lua
plugins – but I only used the most basic ones. Note: the Xournal++
User Guide is currently WIP but the User Manual in Github is quite complete.
Xournal++
worked out of the box. During the presentation I used the out-of-the-box configuration of Xournal++
in Presentation Mode. My window looked like this:
Then, I simply shared a portion of my screen in Zoom to crop out the toolbars.
Navigation during the presentation: keyboard shortcuts
The three essential keyboard shortcuts in Xournal++:
- Go to previous/next slide: Ctrl + PageUp/ PageDown
- Switch to the
Eraser
tool: Shift + Ctrl + E - Switch to the
Pen
tool: Shift + Ctrl + P
Note: when going back and forth between slides, the position of the slide can sometimes change slightly. I need to look into this, but it was not problematics for the talk because the change was small enough.
Xournal++: going further
While writing down this setup for future reference, I realized that there was low-hanging fruit in making my setup better.
Here are some of the problems I encountered using the talk… Note that these are all linked to default behavior in Xournal++ and do not represent actual limitations of the software. We’ll see that they can all be easily fixed.
Multiple monitors
I had initially planned on using my external monitor for the presentation and my laptop screen for seeing faces. However, the tablet was mapped to the union of both monitors which made drawing difficult. Here’s an example of how that impacted my ability to annotate:
This fix was a bit hacky… what if I had really needed the second monitor, e.g. for notes?
In retrospect, I should have remapped the tablet to a single monitor, and used relative tracking. In System Settings > Wacom Tablet
Default eraser behavior
By default, the eraser is in whiteout
mode. It removes any content where it is applied and replaces with white pixels. This is true for both the PDF content (i.e. the slides) and any pen strokes I addded. Two consequences: I would remove content from the slides (which isn’t the goal in general) and the resulting white pixels would be more white that the off-white background my PDF had…
The fix is very simple: change eraser behavior from whiteout
to delete stroke
.
Note: settings are saved from one session to the next so you shouldn’t have to reset this every time.
Adding pages
At one point I ran out of space on a slide. To continue the explanation, an easy solution is to add a page. However, to be able to export the PDF of the annotations afterwards, it is best to keep all the pages the same size.
To configure adding a new page there are two steps:
- Choose the paper type:
Xournal++
offers many options. - Configure the paper size: choose to keep the current size which will adapt to your presentation.
Note that it may be necessary to duplicate a slide, for example to answer two separate questions concerning the same slide. This requires chaning the default background which a bit long to do during the presentation. It is best to go to a new blank slide instead.
Wrap-up
Xournal++
works perfectly for my (rather simple) needs. If you know of alternatives, don’t hesitate to let me know!
Xournal++
is a very active project and is looking to be more widely known. Check out their Github issues if you’d like to help whether in the code or in documentation and outreach.
- Especially my Professors at Sorbonne Unversité, and all those who have been giving pandemic seminars online! Another source of inspiration is Arthur Carpentier, who has been posting lectures online. ⏎
- I won't be getting into how to install these here. ⏎


[gecode-users] simple example
hamza bouchaour
hammallozy at hotmail.com
Mon Jun 29 14:51:07 CEST 2009
Hi everyone, I'm searching for a small example to solving this constraint
2 sets of integer elements (redandance is accepted), verify if the elements of set 1 are present in set 2 and also if they have the same cardinality
Can you help me, I'll use it as starting point.
Thanks
_________________________________________________________________
Découvrez Windows Live Spaces et créez votre site Web perso en quelques clics !
http://spaces.live.com/signup.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20090629/ee6826d0/attachment.htm>
More information about the gecode-users
mailing list