Re: Sending secure mail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

on 02/04/2007 10:22 PM Rob said the following:
> 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?

You may want to take a look at this popular SMTP client class. It
supports TLS. The example demonstrates how to send message via Gmail,
which requires TLS.

http://www.phpclasses.org/smtpclass

Anyway, I recommend that you use that class in conjunction with this
other for composing and sending RFC compliant MIME message. It helps
avoid problems that make message get trapped in spam filters:

http://www.phpclasses.org/mimemessage

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux