Sending secure mail



I need to send a large number of emails (not spam!) through an external
SMTP server that requires TLS and a username/password. I have some
control over the SMTP server but very little over the web server where
the scripts reside. How do I connect with TLS, authenticate and send the
mail?

I had problems with mail() originally (one of the reasons why we now
have a dedicated mail server) and I had to connect to the SMTP server by
hand with sockets and go through the SMTP steps by hand. I can connect
to the new server with following code.

$sock = fsockopen( 'smtp.eg.com', 25, $errNo, $errStr );

However, when I send the "rcpt to:" line, I'm told I don't have access
to the relay - i.e. I need to log in. This is where my knowledge of SMTP
reaches it's limit but I've read about the "auth login" command,
however, it says it needs to be run over an encrypted connection, i.e.
TLS. I can't disable this on the server, other services need TLS to be
on the SMTP server.

I've tried changing "smtp.example.com" to "tls://smtp.example.com" but
it then fails to connect at all ($errNo is "115", $errStr is "Operation
now in progress"). If I connect and send starttls, I don't get any more
data from the server and I've no idea what it's waiting for, be it a
public key or whatever. FWIW, the email server's certificate is a dodgy,
home made one which throws up a security error when tested with a mail
client, but once accepted it is fine.

Is there an easier way to do this? If not, how do I get the connection
so I can get to and "rcpt to:" line and beyond?

Thanks,
Rob
.



Relevant Pages

  • Re: [PHP] Sending secure mail
    ... I suspect that there are pre-built PHP classes out there that can ... SMTP server that requires TLS and a username/password. ...
    (php.general)
  • Re: Sending secure mail
    ... SMTP server that requires TLS and a username/password. ... PHP Classes - Free ready to use OOP components written in PHP ...
    (php.general)
  • Re: Help! Sending Emails From asp.net Application
    ... The biggest problem I've seen when using an smtp server to send emails ... is that the connection limit is easily surpassed because the system can ... The SMTP server service does the rest... ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Pesky virus
    ... If its open relay they can; you can configure your email server to have ... your users authenticate before connecting to the smtp server then its ... emails for verification. ...
    (Fedora)
  • Re: Can Not Send Email in Outlook Express - Error 10060 / 0x800CCC0e
    ... I simply can not sen emails from outlook express (nor any other ... The connection to the server has failed. ... I am on a Comcast DSL Internet connection, ... The chances are that the ISP you are connected to is blocking poer 25 for every SMTP server byt their own. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)