POP3、SMTP邮件收发程序_PHP教程
程序员文章站
2022-05-07 09:17:58
...
if ($EMAIL_INC) return;
$EMAIL_INC= "defined";
define( "SmtpPort",25);
class Pop3 {
var $subject; // 邮件主题
var $from_email; // 发件人地址
var $from_name; // 发件人姓名
var $to_email; // 收件人地址
var $to_name; // 收件人姓名
var $body; // 邮件内容
var $filename; // 文件名
var $socket; // 当前的 socket
var $Line;
var $Status;
function pop3_open($server, $port)
{
$this->Socket = fsockopen($server, $port);
if ($this->Socket 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 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;
$EMAIL_INC= "defined";
define( "SmtpPort",25);
class Pop3 {
var $subject; // 邮件主题
var $from_email; // 发件人地址
var $from_name; // 发件人姓名
var $to_email; // 收件人地址
var $to_name; // 收件人姓名
var $body; // 邮件内容
var $filename; // 文件名
var $socket; // 当前的 socket
var $Line;
var $Status;
function pop3_open($server, $port)
{
$this->Socket = fsockopen($server, $port);
if ($this->Socket 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 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;
推荐阅读
-
Python使用POP3和SMTP协议收发邮件的示例代码
-
用PHP实现POP3邮件的解码(一)_PHP教程
-
CodeIgniter 发送邮件(smtp)_PHP教程
-
PHPMailer使用Gmail来发送邮件的连接smtp服务器错误_PHP教程
-
php下使用SMTP发邮件的代码_PHP教程
-
发送邮件SMTP Error Could not connect to SMTP host. send fail的解决办法_PHP教程
-
ecshop实现smtp发送邮件_PHP教程
-
ecshop实现smtp发送邮件_PHP教程
-
让Hostmonster的网站程序也能发送邮件_PHP教程
-
PHP mail 通过Windows的SMTP发送邮件失败的解决方案_PHP教程