用socket发邮件 有个有关问题
程序员文章站
2022-06-09 19:59:03
...
用socket发邮件 有个问题
我看网上的用socket发邮件
基本上都是吧内容让在
Subject :
XXXXXXX 就是这个地方了
.
但是我加了标签之后如div
总是会被转义
那在内容中放张图片进去 直接接收不到了......郁闷
改怎么办了???
代码如下
我看网上的用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",相关文章
相关视频
推荐阅读
-
发邮件的有关问题,有做过的请进
-
请教有没有人用过traits类型?有个有关问题需要问
-
初学PHP,有一个有关问题
-
有搞过gmagick的吗,咨询个有关问题
-
用socket发邮件 有个有关问题
-
php 重定向出了有关问题,求大神帮助,小弟我发誓已经找了6个小时了,还是没有找出哪里有有关问题
-
数据库查询中一个百思不得其解的有关问题,有详细说明
-
很简单的一个insert有关问题,但是就是有有关问题,请大家帮忙看看到底哪里有有关问题
-
数据库查询中一个百思不得其解的有关问题,有详细说明
-
问一个有关问题 不知道是不是有关问题 ,就是CSDN forumID=c5eca554-e88a-47bd-873d-58c8014f2f91 后面这一串字符,有什么用