PHP authentication method of landing via SMTP mail _php tips

Source: Internet
Author: User
Tags explode php introduction mail account

The example in this article describes the way that PHP validates the login via SMTP mail. Share to everyone for your reference, specific as follows:

Intranet system for the unified account, the use of mail account login method, so the following procedures

/** * by mail Verification login * Here to understand is that the user name is with domain name: aaa@163.com/function Valideemaillogin ($user, $pass, $smtp _server= ' smtp.163.com ', $ PORT=25) {$handle = Fsockopen ($smtp _server, $port); if (! $handle) return false; $mes = Fgets ($handle);//echo $mes; if (! $m
ES) {fclose ($handle); return false;} $status = Explode ("", $mes); if ($status [0]!= 220) {//Link server failed fclose ($handle); return false;} fwrite ($handle, ' HELO mystore '. ') \ r \ n ");
Identify, here's mystore is casually written $mes = fgets ($handle);
Echo $mes;
if (! $mes) {fclose ($handle); return false;} $status = Explode ("", $mes); if ($status [0]!= 250) {//server Helo failed fclose ($handle); return false;} fwrite ($handle, ' AUTH LOGIN '.]
\ r \ n ");
$mes = fgets ($handle);
Echo $mes;
if (! $mes) {fclose ($handle); return false;} $status = Explode ("", $mes); if ($status [0]!= 334) {//Request Verify Login Failed fclose ($handle); return false;} fwrite ($handle, Base64_encode ($user). "
\ r \ n ");
$mes = fgets ($handle);
Echo $mes;
if (! $mes) {fclose ($handle); return false;} $status = Explode ("", $mes); if ($status [0]!= 334 {//Verify user name failed fclose ($handle); return false;} fputs ($handle, Base64_encode ($pass). " 
\ r \ n ");
$mes = fgets ($handle);
Echo $mes;
if (! $mes) {fclose ($handle); return false;} $status = Explode ("", $mes);
Fclose ($handle); if ($status [0]!= 235) {//Verify password failed return false;}

 else{return true;}}

More about PHP Interested readers can view the site topics: "PHP Socket Usage Summary", "PHP Network Programming Skills Summary", "PHP Array" operation Skills Encyclopedia, "PHP Mathematical Operation Skills Summary", "PHP graphics and pictures Operating skills summary", " PHP Operations Office Document Tips summary (including word,excel,access,ppt), "PHP Date and Time usage summary", "PHP Introduction to Object-oriented Programming", "PHP string (String) Usage Summary", "php+ MySQL Database operations Introduction tutorial and PHP Common database operation Skills Summary

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.