Eric & Sherrell | 31 Oct 2011 14:52
Picon
Favicon

SMTP with TSL

Hi everyone,

I've been trying to use cURL with a tsl connection to an smtp server.  I've found the following problems:

1.  PHP curl with telnet and tsl can't connect.  Anyone know how to do this?
2.  There seems to be no SMTP support with the php libraries.  However I saw this example for libcurl: 
http://curl.haxx.se/libcurl/c/smtp-tls.html.  Does this mean it might be coming?

Hacked Solution:
Using curl with an https connection I was able to find a hack that allowed me to send out simple SMTP messages
by putting the entire smtp command strings and message into the customrequest field setting when
connecting to the server.  Example snipit:

        curl_setopt($this->curl_handle, CURLOPT_URL, "https://$this->host:$this->port";);
        curl_setopt($this->curl_handle, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt($this->curl_handle, CURLOPT_SSL_VERIFYHOST, true);
        curl_setopt($this->curl_handle, CURLOPT_CAINFO, "cacert.pem"); // local root CA copy
        curl_setopt($this->curl_handle, CURLOPT_CAPATH, "./");
        curl_setopt($this->curl_handle, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($this->curl_handle, CURLOPT_HTTPHEADER, "");

        $out = "AUTH LOGIN\r\n";
        $out .= base64_encode($this->user) . "\r\n";
        $out .= base64_encode($this->password) . "\r\n";
        $out .= "MAIL FROM: <$from>\r\n";
        $out .= "RCPT TO: <$to>\r\n";
        $out .= "DATA\r\n";
        $out .= "To: $to\r\n";
        $out .="From: $from\r\n";
        $out .="Subject:  $subject\r\n\r\n";
(Continue reading)

Daniel Stenberg | 31 Oct 2011 21:49
Picon
Favicon
Gravatar

Re: SMTP with TSL

On Mon, 31 Oct 2011, Eric & Sherrell wrote:

> 1.  PHP curl with telnet and tsl can't connect.  Anyone know how to do this?

Telnet? How is that related to SMTP here? There's no telnet with TLS...

> 2.  There seems to be no SMTP support with the php libraries.  However I saw 
> this example for libcurl:  http://curl.haxx.se/libcurl/c/smtp-tls.html.  
> Does this mean it might be coming?

It has been present in libcurl since February 2010. I think you need to step 
forward and help your fellow PHP users get access to this functionalty by 
extending the PHP/CURL extension.

> Using curl with an https connection I was able to find a hack that allowed 
> me to send out simple SMTP messages by putting the entire smtp command 
> strings and message into the customrequest field setting when connecting to 
> the server.

Clever! But still just a hack...

> If you have any more stable ideas or solutions, I would love to hear them.

Adding support to PHP/CURL for the small set of new options that SMTP needs 
should be REALLY easy.

--

-- 

  / daniel.haxx.se
(Continue reading)


Gmane