Home > Backend Development > PHP Tutorial > POP3, SMTP mail sending and receiving program_PHP tutorial

POP3, SMTP mail sending and receiving program_PHP tutorial

WBOY
Release: 2016-07-13 16:54:10
Original
986 people have browsed it

if ($EMAIL_INC) return;
$EMAIL_INC= "defined";
define( "SmtpPort",25);
class Pop3 {
var $subject; / / Email subject
var $from_email; // Sender address
var $from_name; // Sender name
var $to_email; // Recipient address
var $to_name; / / Recipient name
var $body; // Email content
var $filename; // File name
var $socket; // Current socket
var $Line;
var $Status;
function pop3_open($server, $port)
{
$this->Socket = fsockopen($server, $port);
if ($this->Socket < ;= 0){
return false;
}
$this->Line = fgets($this->Socket, 1024);
$this->Status[ "LASTRESULT" ] = substr($this->Line, 0, 1);
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024);
if ( $this->Status[ "LASTRESULT"] <> "+") return false;
return true;
}
function pop3_user($user)
{
if ( $this->Socket < 0){
return false;
}
fputs($this->Socket, "USER $this->userrn");
$this- >Line = fgets($this->Socket, 1024);
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1);
$this ->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024);
if ($this->Status[ "LASTRESULT"] <> "+") return false ;
return true;
}
function pop3_pass( $pass)
{
fputs($this->Socket, "PASS $passrn");
$this-> ;Line = fgets($this->Socket, 1024);
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1);
$this- >Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024);
if ($this->Status[ "LASTRESULT"] <> "+") return 0;
return 1;
}
function pop3_stat()
{
fputs($this->Socket, "STATrn");
$this->Line = fgets( $this->Socket, 1024);
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status[ " LASTRESULTTXT"] = substr($this->Line, 0, 1024);
if ($this->Status[ "LASTRESULT"] <> "+") return 0;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631811.htmlTechArticle?php if ($EMAIL_INC) return; $EMAIL_INC= "defined"; define( "SmtpPort",25) ; class Pop3 { var $subject; // Email subject var $from_email; // Sender address var $from_name; // Sender...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template