PHP authentication via SMTP mail login method, PHPSMTP mail Verification _php Tutorial

Source: Internet
Author: User
Tags mail account

PHP authentication via SMTP mail login method, PHPSMTP mail authentication


This article explains how PHP logs on through SMTP mail verification. Share to everyone for your reference, as follows:

Intranet system in order to unify the account, all use the mail account login way, so there are the following procedures

/*** via email authentication * Here to understand is the user name is with the 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 (! $mes {fclose ($handle); return false;} $status = Explode ("", $mes); if ($status [0]! = 220) {//Link server failed fclose ($handle); return false;} Fwrite ($handle, ' HELO mystore '. \ r \ n "); Indicate identity, where the 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 verification 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 related content readers can view this site topic: "PHP Socket Usage Summary", "PHP Network Programming Skills Summary", "PHP array" operation Skills Daquan, "PHP Math Skills Summary", "PHP graphics and pictures Operation Skills Summary", " PHP Operations Office Documentation Tips Summary (including word,excel,access,ppt), PHP date and Time usage summary, PHP Object-oriented Programming primer tutorial, PHP string Usage Summary, php+ MySQL database operation Getting Started tutorial and PHP Common database operation Skills Summary

I hope this article is helpful to you in PHP programming.

http://www.bkjia.com/PHPjc/1125879.html www.bkjia.com true http://www.bkjia.com/PHPjc/1125879.html techarticle PHP through the SMTP mail authentication method, PHPSMTP mail authentication This article describes the PHP through the SMTP mail authentication method of landing. Share to everyone for reference, as follows: Intranet ...

  • 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.