验证邮箱的真实性而非格式
<?php set_time_limit(120); class smtp_mail { var $host; //主机 var $port; //端口 一般为25 var $user; //SMTP认证的帐号 var $pass; //认证密码 var $debug = false; //是否显示和服务器会话信息? var $conn; var $result_str; //结果 var $in; //客户机发送的命令 var $from; //源信箱 var $to; //目标信箱 var $subject; //主题 var $body; //内容 function smtp_mail($host,$port,$user,$pass,$debug=false) { $this->host = $host; $this->port = $port; $this->user = base64_encode($user); $this->pass = base64_encode($pass); $this->debug = $debug; $this->socket = socket_create (AF_INET, SOCK_STREAM, SOL_TCP); //具体用法请参考手册 if($this->socket) { $this->result_str ="创建SOCKET:".socket_strerror(socket_last_error()); $this->debug_show($this->result_str); } else { exit("初始化失败,请检查您的网络连接和参数"); } $this->conn = socket_connect($this->socket,$this->host,$this->port); if($this->conn) { $this->result_str ="创建SOCKET连接:".socket_strerror(socket_last_error()); $this->debug_show($this->result_str); } else { exit("初始化失败,请检查您的网络连接和参数"); } $this->result_str ="服务器应答:<font color=#cc0000>".socket_read ($this->socket, 1024)."</font>"; $this->debug_show($this->result_str); } function debug_show($str) { if($this->debug) { echo $str."<p>rn"; } } function send($from,$to,$subject,$body) { if($from ==""|| $to =="") { exit("请输入信箱地址"); } if($subject =="") $sebject ="无标题"; if($body =="") $body ="无内容"; $this->from = $from; $this->to = $to; $this->subject = $subject; $this->body = $body; //扬帆修改部分代码 $All ="From:<".$this->from.">rn"; $All .="To:<".$this->to.">rn"; $All .="Subject:".$this->subject."rnrn"; $All .= $this->body; //以下是和服务器会话 $this->in ="EHLO HELOrn"; $this->docommand(); $this->in ="AUTH LOGINrn"; $this->docommand(); $this->in = $this->user."rn"; $this->docommand(); $this->in = $this->pass."rn"; $this->docommand(); // $this->in ="MAIL FROM:".$this->from."rn"; $this->in ="MAIL FROM:<".$this->from.">rn"; //扬帆修改 $this->docommand(); // $this->in ="RCPT TO:".$this->to."rn"; $this->in ="RCPT TO:<".$this->to.">rn"; //扬帆修改 $this->docommand(); $this->in ="DATArn"; $this->docommand(); $this->in = $All."rn.rn"; $this->docommand(); $this->in ="QUITrn"; $this->docommand(); //结束,关闭连接 } function docommand() { socket_write ($this->socket, $this->in, strlen ($this->in)); $this->debug_show("客户机命令:".$this->in); $this->result_str ="服务器应答:<font color=#cc0000>".socket_read ($this->socket, 1024)."</font>"; $this->debug_show($this->result_str); } } ?>
<?php //测试页面 include"smtp_mail.php"; //你用这个类的时候你修改成你自己的信箱就可以了 $smtp=new smtp_mail("smtp.qq.com","25","yourmail@qq.com","Your password",true); //如果你需要显示会话信息,请将上面的修改成 //$smtp = new smtp_mail("smtp.qq.com","25","你的qq.com的帐号","你的密码",true); $smtp->send("yourmail@qq.com","yourmail@qq.com","你好","测试邮件"); ?>

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

查找方法:1、用strpos(),语法“strpos("字符串值","查找子串")+1”;2、用stripos(),语法“strpos("字符串值","查找子串")+1”。因为字符串是从0开始计数的,因此两个函数获取的位置需要进行加1处理。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

WebStorm Mac版
好用的JavaScript開發工具

Dreamweaver Mac版
視覺化網頁開發工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

記事本++7.3.1
好用且免費的程式碼編輯器