Authorization by the POP protocol before using the SMTP
Sometimes it can happen that you need to send the e-mail via the mail server but you don’t have an access. There are several ways out. First, you can ask your provider to give their mail server address and access to it. Second, you can use free mail servers, there are plenty of them in the Internet. Third, you can authorize on the mail server. That method is the most appropriate one in the case if your provider doesn’t give you an opportunity of sending mail via their server. The advantage of second method is that you can send your mail anonymously (another words you can spam). But if you are not the spammer, you don’t need this. All the more such servers as usual are unreliable and unsafe. I tried all variants. After all my attempts I began to search alternative ways. I have the list of the free servers but some of them didn’t response or worked very slowly. Such public servers are used by spammers, that’s why they are tracked and cut off. The last way out is to send mail from the free mail sites, such as hotmail.com, yahoo.com, gmail.com etc. But here we have one problem. If have ever sent mail using the mail client you have to know that there is such option as SMTP authorization using. The only way out is to authorize before sending mail. But the problem is that server identifies you according to your IP-address without requiring login and password. If you entered the server by POP protocol and successfully authorized server gives the access for a definite time (it depends on the service, it can be 15-30 minutes). If you changed your IP (for example after disconnect) server won’t give the access. Authorization will take few strings. POP protocol has standard authorization commands:
USER – sets the user name
PASS – sets the password
You can use standard socket opening procedures for connecting to the server. You have to indicate the POP server’s port (usually 110), open the connection, authorize and close the connection. After that you can connect to the SMTP server and send your message. Here the example of the script for the mail sending with preliminary authorization:
$server = "mail.yahoo.com";
$user = "avanes";
$pass = "vah";
// POP authorization
$fp = fsockopen($server, 110, &$errno, &$errstr, 30);
fputs($fp,"USER $user\n");
$s = fgets($fp);
fputs($fp,"PASS $pass\n");
$s = fgets($fp);
fputs($fp,"QUIT\n");
// SMTP sending
$fp = fsockopen($server, 25, &$errno, &$errstr, 30);
$s = fgets($fp);
fputs($fp,"HELLO www.test.com. \n");
$s = fgets($fp);
$s = explode(" ",$s);
fputs($fp,"MAIL FROM:\n");
$s = fgets($fp);
fputs($fp,"RCPT TO:<$to>\n");
$s = fgets($fp);
fputs($fp,"DATA\n");
$s = fgets($fp);
fputs($fp,"$mess");
fputs($fp,"\n.\n");
$s = fgets($fp);
fputs($fp,"QUIT\n");
fclose($fp);
That’s it. Don’t forget to open your mail box on that server before authorization.



