欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

用socket发邮件 有个有关问题

程序员文章站 2022-06-09 19:59:03
...
用socket发邮件 有个问题
我看网上的用socket发邮件
基本上都是吧内容让在
Subject :

XXXXXXX 就是这个地方了
.

但是我加了标签之后如div
总是会被转义

那在内容中放张图片进去 直接接收不到了......郁闷
改怎么办了???
代码如下


class aMail{
public static $smtp_prot = 25;
public static $debug = true;
public static $crlf = "\r\n";
var $smtp_host;
var $login_name;
var $password;
var $form;
var $to;
var $err;
var $message;
var $socket;
function __construct($options=""){
if($options == "" || !is_array($options)){
return false;
}
foreach($options as $key=>$val){
$this->$key = $val;
}
}

function sendMail(){
$this->socket = fsockopen($this->smtp_host,self::$smtp_prot);
$socket = $this->socket;
$crlf = self::$crlf;
stream_set_blocking($socket,true);
$this->message = fgets($socket,512);
echo $this->message;
if(!$this->print_messsage("/^220/","connect fail")){
return false;
}

fputs($socket,"EHLO 127.0.0.1 ".$crlf);
$this->message = fgets($socket, 512);
if(!$this->print_messsage("/^2/","EHLO fail")){
return false;
}

fputs($socket,"AUTH LOGIN".$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^2/","AUTH LOGIN fail");

fputs($socket,base64_encode($this->login_name).$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^2/","login_name fail");

fputs($socket,base64_encode($this->password).$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^2/","password fail");

fputs($socket,"MAIL FROM: from.">".$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^2/","from fail");

fputs($socket,"RCPT TO: to.">".$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^334|^2/","to fail");

fputs($socket,"DATA".$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^334|^2/","DATA fail");

$html = implode("",array(
"To: ".$this->to.$crlf,
"From: ".$this->from.$crlf,
"Subject: ".$this->subject.$crlf.$crlf,
$this->content.$crlf.".".$crlf,
));

fputs($socket,$html);
$this->message = fgets($socket, 512);
$this->print_messsage("/^2/","html fail");

fputs($socket, "QUIT".$crlf);
$this->message=fgets($socket,512);
$this->print_messsage("/^2/","QUIT fail");
}
function print_messsage($reg="",$err=""){
$message = $this->message;
if(preg_match($reg,$message) $this->err = $err."___".$message."--------------";
echo $err."___".$message."--------------
";
return false;
}
if(self::$debug){
echo $this->message."
";
}
return true;
}
}
$mail_options = array(
"smtp_host"=>"smtp.sina.com.cn",
"login_name"=>"ycwtt0527",
用socket发邮件 有个有关问题

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频