Jump to content

SMTP authentication?


B0b

Recommended Posts

Hello,

 

I am trying to send an email from an Hotmail account, but hotmail doesn't recognise "AUTH LOGIN" command? May you tell me why?

 

Here's how it looks like:

 

getmxrr( 'hotmail.com', $MXs );
$sock = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
socket_connect( $sock, $MXs[0], 25 );
echo socket_read( $sock, 2082 ); // 220 bay0-mc1-f27.Bay0.hotmail.com...
socket_write( $sock, 'EHLO mydomain.com' . "\r\n" );
echo socket_read( $sock, 2082 ); // 250-bay0-mc1-f27.Bay0.hotmail.com (3.11.0.113)...
socket_write( $sock, base64_encode( 'AUTH LOGIN' ) . "\r\n" );
echo socket_read( $sock, 2082 ); // This returns 500 Unrecognized command 

Link to comment
https://forums.phpfreaks.com/topic/204880-smtp-authentication/
Share on other sites

Thanks for your input Ken. I don't know why there's a base64_encode there, but my situation has evolved since my last message.

My goal is simply to send out an email from an Hotmail account (it. through SMTP authentication).

 

Here's how the code looks like right now:

 

<?php

$sock = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
socket_bind( $sock, 'XX.XX.XX.XX' );

socket_connect( $sock, 'smtp.live.com', 25 );

socket_write( $sock, 'EHLO mydomain' . "\r\n" );
socket_write( $sock, 'STARTTLS' . "\r\n"  );
socket_write( $sock, 'EHLO mydomain' . "\r\n" );
socket_write( $sock, 'AUTH LOGIN' . "\r\n" );
socket_write( $sock, 'myemail' . "\r\n" );
socket_write( $sock, 'mypassword' . "\r\n" );
socket_write( $sock, 'MAIL FROM: <anotheremail>' . "\r\n" ); // And this will output this error: "Connection reset by peer".

 

I've been told Hotmail requires an SSL connection and fsockopen would solve this, but I got to bind an IP address to my socket, so here I am.

Link to comment
https://forums.phpfreaks.com/topic/204880-smtp-authentication/#findComment-1072716
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.