Net::Server::Mail::ESMTP::STARTTLS(3) A module to support the STARTTLS command in Net::Server::Mail::ESMTP


use strict;
use Net::Server::Mail::ESMTP;
my @local_domains = qw(;
my $server = IO::Socket::INET->new( Listen => 1, LocalPort => 25 );
my $conn;
while($conn = $server->accept)
my $esmtp = Net::Server::Mail::ESMTP->new(
socket => $conn,
SSL_config => {
SSL_cert_file => 'your_cert.pem',
SSL_key_file => 'your_key.key',
# Any other options taken by IO::Socket::SSL

# activate some extensions

# adding optional STARTTLS handler
$esmtp->set_callback(STARTTLS => \&tls_started);

sub tls_started {
my ($session) = @_;
# Now, allow authentication


This module conducts a TLS handshake with the client upon receiving the STARTTLS command. It uses IO::Socket::SSL, requiring 1.831+, to perform the handshake and secure traffic.

An additional option, SSL_config, is passed to Net::Server::Mail::ESMTP's constructor. It contains options for IO::Socket::SSL's constructor. Please refer to IO::Socket::SSL's perldoc for details.


This module has been written by Xavier Guimard <[email protected]> using libs written by:
Mytram <[email protected]>
Dan Moore "<dan at>"


Available on CPAN.

anonymous Git repository:

git clone git://

Git repository on the web:



Please use CPAN system to report a bug (


Copyright (C) 2009 - Dan Moore <dan at>
Copyright (C) 2013 - Mytram <[email protected]>
Copyright (C) 2013 - Xavier Guimard <[email protected]>

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.