php socket 使用smtp服务器发送邮件

 更新时间:2016年11月25日 17:01  点击:2017

/*邮件发送类
*功能:php教程 socket 使用smtp服务器发送邮件
*作者:longlong
*时间:2007-11-26
*转帖请加本贴引用地址:showpost.asp教程?threadid=1345 
*/
class smtp
{
/* 全局变量 */
var $smtp_port;
var $time_out;
var $host_name;
var $log_file;
var $relay_host;
var $debug;
var $auth;
var $user;
var $pass;

/* private variables */ 
var $sock;

/* 构造函数 */

function smtp($relay_host = "", $smtp_port = 25,$auth = false,$user,$pass)
{
  $this->debug = false;
  $this->smtp_port = $smtp_port;
  $this->relay_host = $relay_host;
  $this->time_out = 30; //is used in fsockopen() 
   
  #

  $this->auth = $auth;//auth
  $this->user = $user;
  $this->pass = $pass;
   
  #

  $this->host_name = "localhost"; //is used in helo command 
  $this->log_file = "";


  $this->sock = false;
}

/* 主函数,发送邮件 */

function sendmail($flag, $boundary, $to, $from, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "")
{
  $mail_from = $this->get_address($this->strip_comment($from));
  $body = ereg_replace("(^|(rn))(.)", "1.3", $body);
  $header = "mime-version:1.0rn";
   
  //*
  if($mailtype=="html"){
  //echo $boundary;exit;
if($flag==2)
{
  $header .= "content-type:multipart/mixed; boundary= $boundaryrn";
  //$header .= "content-type:text/htmlrn";
}
else

  $header .= "content-type:text/htmlrn";
}
  }
  //*/

  $header .= "to: ".$to."rn";

  if ($cc != "") {
  $header .= "cc: ".$cc."rn";
  }

  $header .= "from: $from<".$from.">rn";
  $header .= "subject: ".$subject."rn";
  $header .= $additional_headers;
  $header .= "date: ".date("r")."rn";
  $header .= "x-mailer:by redhat (php/".phpversion().")rn";

  //$header.=$body;//edit by shaolong
  
  list($msec, $sec) = explode(" ", microtime());

  $header .= "message-id: <".date("ymdhis", $sec).".".($msec*1000000).".".$mail_from.">rn";

  $to = explode(",", $this->strip_comment($to));

  if ($cc != "") {
  $to = array_merge($to, explode(",", $this->strip_comment($cc)));
  }


  if ($bcc != "") {
  $to = array_merge($to, explode(",", $this->strip_comment($bcc)));
  }

  $sent = true;

  foreach ($to as $rcpt_to) {
  $rcpt_to = $this->get_address($rcpt_to);
   
  if (!$this->smtp_sockopen($rcpt_to)) {
  $this->log_write("error: cannot send email to ".$rcpt_to."n");
  $sent = false;
  continue;
  }

  if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)) {
  $this->log_write("e-mail has been sent to <".$rcpt_to.">n");
  } else {
  $this->log_write("error: cannot send email to <".$rcpt_to.">n");
  $sent = false;
  }

  fclose($this->sock);

  $this->log_write("disconnected from remote hostn");
  }
  return $sent;
}

/* 私有函数 */

function smtp_send($helo, $from, $to, $header, $body = "")
{
  if (!$this->smtp_putcmd("helo", $helo)) {

  return $this->smtp_error("sending helo command");
  }

  #auth

  if($this->auth){
  if (!$this->smtp_putcmd("auth login", base64_encode($this->user))) {
  return $this->smtp_error("sending helo command");
  }

  if (!$this->smtp_putcmd("", base64_encode($this->pass))) {
  return $this->smtp_error("sending helo command");
  }
  }

  #

  if (!$this->smtp_putcmd("mail", "from:<".$from.">")) {
  return $this->smtp_error("sending mail from command");
  }

  if (!$this->smtp_putcmd("rcpt", "to:<".$to.">")) {
  return $this->smtp_error("sending rcpt to command");
  }

  if (!$this->smtp_putcmd("data")) {
  return $this->smtp_error("sending data command");
  }

  if (!$this->smtp_message($header, $body)) {
  return $this->smtp_error("sending message");
  }


  if (!$this->smtp_eom()) {
  return $this->smtp_error("sending <cr><lf>.<cr><lf> [eom]");
  }


  if (!$this->smtp_putcmd("quit")) {
  return $this->smtp_error("sending quit command");
  }
  return true;
}


function smtp_sockopen($address)
{
  if ($this->relay_host == "") {

  return $this->smtp_sockopen_mx($address);

  } else {
  return $this->smtp_sockopen_relay();
  }
}


function smtp_sockopen_relay()
{
  $this->log_write("trying to ".$this->relay_host.":".$this->smtp_port."n");

  $this->sock = @fsockopen($this->relay_host, $this->smtp_port, $errno, $errstr, $this->time_out);

  if (!($this->sock && $this->smtp_ok())) {

  $this->log_write("error: cannot connenct to relay host ".$this->relay_host."n");

  $this->log_write("error: ".$errstr." (".$errno.")n");

  return false;
  }
  $this->log_write("connected to relay host ".$this->relay_host."n");
  return true;


function smtp_sockopen_mx($address)
{
  $domain = ereg_replace("^.+@([^@]+)$", "1", $address);
  if (!@getmxrr($domain, $mxhosts)) {
  $this->log_write("error: cannot resolve mx "".$domain.""n");
  return false;
  }

  foreach ($mxhosts as $host) {
  $this->log_write("trying to ".$host.":".$this->smtp_port."n");

  $this->sock = @fsockopen($host, $this->smtp_port, $errno, $errstr, $this->time_out);

  if (!($this->sock && $this->smtp_ok())) {
  $this->log_write("warning: cannot connect to mx host ".$host."n");
  $this->log_write("error: ".$errstr." (".$errno.")n");
  continue;
  }

  $this->log_write("connected to mx host ".$host."n");
  return true;
  }

  $this->log_write("error: cannot connect to any mx hosts (".implode(", ", $mxhosts).")n");
  return false;
}


function smtp_message($header, $body)
{
  fputs($this->sock, $header."rn".$body);
  $this->smtp_debug("> ".str_replace("rn", "n"."> ", $header."n> ".$body."n> "));
  return true;
}


function smtp_eom()
{
  fputs($this->sock, "rn.rn");

  $this->smtp_debug(". [eom]n");

  return $this->smtp_ok();
}


function smtp_ok()
{
  $response = str_replace("rn", "", fgets($this->sock, 512));
  $this->smtp_debug($response."n");

  if (!ereg("^[23]", $response)) {
  fputs($this->sock, "quitrn");
  fgets($this->sock, 512); 
  $this->log_write("error: remote host returned "".$response.""n");
  return false;

  }
  return true;
}


function smtp_putcmd($cmd, $arg = "")
{
  if ($arg != "") {
  if($cmd=="") $cmd = $arg;
  else $cmd = $cmd." ".$arg;
  }

  fputs($this->sock, $cmd."rn");
  $this->smtp_debug("> ".$cmd."n");
  return $this->smtp_ok();
}


function smtp_error($string)
{
  $this->log_write("error: error occurred while ".$string.".n");
  return false;
}


function log_write($message)
{
  $this->smtp_debug($message);
  if ($this->log_file == "") {

  return true;
  }

  $message = date("m d h:i:s ").get_current_user()."[".getmypid()."]: ".$message;
  if (!@file_exists($this->log_file) || !($fp = @fopen($this->log_file, "a"))) {
  $this->smtp_debug("warning: cannot open log file "".$this->log_file.""n");
  return false;;
  }

  flock($fp, lock_ex);
  fputs($fp, $message);
  fclose($fp);
  return true;
}

function strip_comment($address)
{
  $comment = "([^()]*)";
  while (ereg($comment, $address)) {
  $address = ereg_replace($comment, "", $address);
  }
  return $address;
}

function get_address($address)
{
  $address = ereg_replace("([ trn])+", "", $address);
  $address = ereg_replace("^.*<(.+)>.*$", "1", $address);
  return $address;
}


function smtp_debug($message)
{
  if ($this->debug) {
  echo $message;
  }
}
}

php教程 fsockopen邮箱发送实例代码

<?
//ok的邮箱发送。
include "smtp.class.php";
//$smtps教程erver = "smtp.163.com"; //您的smtp服务器的地址
$smtpserver="smtp.163.com";
$port =25; //smtp服务器的端口,一般是 25
$smtpuser = "你的邮箱@163.com"; //您登录smtp服务器的用户名
$smtppwd = "你邮箱的密码"; //您登录smtp服务器的密码
$mailtype = "txt"; //邮件的类型,可选值是 txt 或 html ,txt 表示是纯文本的邮件,html 表示是 html格式的邮件
$sender = "你的邮箱@163.com";
//发件人,一般要与您登录smtp服务器的用户名($smtpuser)相同,否则可能会因为smtp服务器的设置导致发送失败
$smtp = new smtp($smtpserver,$port,true,$smtpuser,$smtppwd,$sender);
$smtp->debug = true; //是否开启调试,只在测试程序时使用,正式使用时请将此行注释
$to = "你要发给的那个人的邮箱地址"; //收件人
$subject = "你好";
$body = "你发送的内容 ";
$send=$smtp->sendmail($to,$sender,$subject,$body,$mailtype);

if($send==1){
echo "邮件发送成功";
}else{
echo "邮件发送失败<br/>";
//echo "原因:".$this->smtp->logs;
}
?>

邮箱发送类smtp.class.php

<?php
class smtp
{
/* public variables */
var $smtp_port;
var $time_out;
var $host_name;
var $log_file;
var $relay_host;
var $debug;
var $auth;
var $user;
var $pass;
/* private variables */
var $sock;
/* constractor */
function smtp($relay_host = "", $smtp_port = 25,$auth = false,$user,$pass)
{
$this->debug = false;
$this->smtp_port = $smtp_port;
$this->relay_host = $relay_host;
$this->time_out = 30; //is used in fsockopen()
#
$this->auth = $auth;//auth
$this->user = $user;
$this->pass = $pass;
#
$this->host_name = "localhost"; //is used in helo command
$this->log_file = "";
$this->sock = false;
}
/* main function */
function sendmail($to, $from, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "")
{
$mail_from = $this->get_address($this->strip_comment($from));
$body = ereg_replace("(^|(rn))(.)", "1.3", $body);
$header .= "mime-version:1.0rn";
if($mailtype=="html"){
$header .= "content-type:text/htmlrn";
}
$header .= "to: ".$to."rn";
if ($cc != "") {
$header .= "cc: ".$cc."rn";
}
$header .= "from: $from<".$from.">;rn";
$header .= "subject: ".$subject."rn";
$header .= $additional_headers;
$header .= "date: ".date("r")."rn";
$header .= "x-mailer:by redhat (php/".phpversion().")rn";
list($msec, $sec) = explode(" ", microtime());
$header .= "message-id: <".date("ymdhis", $sec).".".($msec*1000000).".".$mail_from.">;rn";
$to = explode(",", $this->strip_comment($to));
if ($cc != "") {
$to = array_merge($to, explode(",", $this->strip_comment($cc)));
}
if ($bcc != "") {
$to = array_merge($to, explode(",", $this->strip_comment($bcc)));
}
$sent = true;
foreach ($to as $rcpt_to) {
$rcpt_to = $this->get_address($rcpt_to);
if (!$this->smtp_sockopen($rcpt_to)) {
$this->log_write("error: cannot send email to ".$rcpt_to."n");
$sent = false;
continue;
}
if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)) {
$this->log_write("e-mail has been sent to <".$rcpt_to.">;n");
} else {
$this->log_write("error: cannot send email to <".$rcpt_to.">;n");
$sent = false;
}
fclose($this->sock);
$this->log_write("disconnected from remote hostn");
}
return $sent;
}
/* private functions */
function smtp_send($helo, $from, $to, $header, $body = "")
{
if (!$this->smtp_putcmd("helo", $helo)) {
return $this->smtp_error("sending helo command");
}
#auth
if($this->auth){
if (!$this->smtp_putcmd("auth login", base64_encode($this->user))) {
return $this->smtp_error("sending helo command");
}
if (!$this->smtp_putcmd("", base64_encode($this->pass))) {
return $this->smtp_error("sending helo command");
}
}
#
if (!$this->smtp_putcmd("mail", "from:<".$from.">;")) {
return $this->smtp_error("sending mail from command");
}
if (!$this->smtp_putcmd("rcpt", "to:<".$to.">;")) {
return $this->smtp_error("sending rcpt to command");
}
if (!$this->smtp_putcmd("data")) {
return $this->smtp_error("sending data command");
}
if (!$this->smtp_message($header, $body)) {
return $this->smtp_error("sending message");
}
if (!$this->smtp_eom()) {
return $this->smtp_error("sending <cr>;<lf>;.<cr>;<lf>; [eom]");
}
if (!$this->smtp_putcmd("quit")) {
return $this->smtp_error("sending quit command");
}
return true;
}
function smtp_sockopen($address)
{
if ($this->relay_host == "") {
return $this->smtp_sockopen_mx($address);
} else {
return $this->smtp_sockopen_relay();
}
}
function smtp_sockopen_relay()
{
$this->log_write("trying to ".$this->relay_host.":".$this->smtp_port."n");
$this->sock = @fsockopen($this->relay_host, $this->smtp_port, $errno, $errstr, $this->time_out);
if (!($this->sock && $this->smtp_ok())) {
$this->log_write("error: cannot connenct to relay host ".$this->relay_host."n");
$this->log_write("error: ".$errstr." (".$errno.")n");
return false;
}
$this->log_write("connected to relay host ".$this->relay_host."n");
return true;
}
function smtp_sockopen_mx($address)
{
$domain = ereg_replace("^.+@([^@]+)$", "1", $address);
if (!@getmxrr($domain, $mxhosts)) {
$this->log_write("error: cannot resolve mx "".$domain.""n");
return false;
}
foreach ($mxhosts as $host) {
$this->log_write("trying to ".$host.":".$this->smtp_port."n");
$this->sock = @fsockopen($host, $this->smtp_port, $errno, $errstr, $this->time_out);
if (!($this->sock && $this->smtp_ok())) {
$this->log_write("warning: cannot connect to mx host ".$host."n");
$this->log_write("error: ".$errstr." (".$errno.")n");
continue;
}
$this->log_write("connected to mx host ".$host."n");
return true;
}
$this->log_write("error: cannot connect to any mx hosts (".implode(", ", $mxhosts).")n");
return false;
}
function smtp_message($header, $body)
{
fputs($this->sock, $header."rn".$body);
$this->smtp_debug(">; ".str_replace("rn", "n".">; ", $header."n>; ".$body."n>; "));
return true;
}
function smtp_eom()
{
fputs($this->sock, "rn.rn");
$this->smtp_debug(". [eom]n");
return $this->smtp_ok();
}
function smtp_ok()
{
$response = str_replace("rn", "", fgets($this->sock, 512));
$this->smtp_debug($response."n");
if (!ereg("^[23]", $response)) {
fputs($this->sock, "quitrn");
fgets($this->sock, 512);
$this->log_write("error: remote host returned "".$response.""n");
return false;
}
return true;
}
function smtp_putcmd($cmd, $arg = "")
{
if ($arg != "") {
if($cmd=="") $cmd = $arg;
else $cmd = $cmd." ".$arg;
}
fputs($this->sock, $cmd."rn");
$this->smtp_debug(">; ".$cmd."n");
return $this->smtp_ok();
}
function smtp_error($string)
{
$this->log_write("error: error occurred while ".$string.".n");
return false;
}
function log_write($message)
{
$this->smtp_debug($message);
if ($this->log_file == "") {
return true;
}
$message = date("m d h:i:s ").get_current_user()."[".getmypid()."]: ".$message;
if (!@file_exists($this->log_file) || !($fp = @fopen($this->log_file, "a"))) {
$this->smtp_debug("warning: cannot open log file "".$this->log_file.""n");
return false;
}
flock($fp, lock_ex);
fputs($fp, $message);
fclose($fp);
return true;
}
function strip_comment($address)
{
$comment = "([^()]*)";
while (ereg($comment, $address)) {
$address = ereg_replace($comment, "", $address);
}
return $address;
}
function get_address($address)
{
$address = ereg_replace("([ trn])+", "", $address);
$address = ereg_replace("^.*<(.+)>;.*$", "1", $address);
return $address;
}
function smtp_debug($message)
{
if ($this->debug) {
echo $message;
}
}
}
function sendmail($smtpserver,$smtpuser,$smtppass,$smtpemailto,$smtpusermail, $mailsubject, $mailbody){
$smtp = new smtp($smtpserver,25,true,$smtpuser,$smtppass);
//$smtp->debug = true;
$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, "html");
}
//such as
//sendmail("smtp.126.com","test@126.com","password","1034555083@qq.com","test@126.com","title","body");
?>

更多关于fsockopen函数请查看

http://www.111cn.net/phper/php-function/33796.htm

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>php发送邮件</title>
</head>

<body>
<table width="611" height="200" border="1">
  <tr>
    <td width="601"><form id="form1" name="form1" method="post" action="send.php">
      <table width="600" height="240" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="102" height="28">收件人地址</td>
          <td width="213"><input name="to" type="text" id="to" /></td>
          <td width="84">发送人地址</td>
          <td width="201"><input name="from" type="text" id="from" value="cert@163.com" /></td>
        </tr>
        <tr>
          <td height="33">发送人用户名</td>
          <td><input name="name" type="text" id="username" value="cert" /></td>
          <td>邮箱密码</td>
          <td><input name="password" type="password" id="password" value="***" /></td>
        </tr>
        <tr>
          <td height="27">smtp服务器</td>
          <td><input name="smtp" type="text" id="smtp" value="smtp.163.com" /></td>
          <td colspan="2">注:163邮箱smtp为: smtp.163.com</td>
          </tr>
        <tr>
          <td height="26">标题</td>
          <td colspan="3"><input name="subject" type="text" id="subject" value="cert测试php发送邮件" size="50" /></td>
          </tr>
        <tr>
          <td height="69">内容</td>
          <td colspan="3"><textarea name="content" cols="50" rows="6" id="content">计算机紧急响应组欢迎你!
http://www.111cn.net
组织网站即将进行改版</textarea></td>
          </tr>
        <tr>
       
          <td>&nbsp;</td>
          <td align="right"><input type="submit" name="submit" value="发送" /></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      </table>
        <p>说明:我用163的邮箱发给 163 或 126 的邮箱立刻就能收到。大家试试。</p>
    </form>
    </td>
  </tr>
</table>
</body>
</html>

<?
require_once 'mail.php';

$conf['mail'] = array(
        'host'     => 'smtp.126.com',                  //smtp服务器地址
        'auth'     => true,                           //true表示smtp服务器需要验证,false不需要
        'username' => 'liangbowen',                   //用户名
        'password' => '******'                        //密码
);


//发送邮件
$headers['from']    = 'liangbowen@126.com';               //发信地址
$headers['to']      = 'liangbowen@hotmail.com';               //收信地址
$headers['subject'] = 'test mail send by php bowen.mvbb.com';   //邮件标题
$mail_object = &mail::factory('smtp', $conf['mail']);   
//邮件正文
$body = "这是一封自己发给自己的邮件。";

$mail_res = $mail_object->send($headers['to'], $headers, $body); //发送

                           
if(pear::iserror($mail_res)){      //检测错误
    die($mail_res->getmessage());
}
else{
 echo "send successful!";
}

源码下载

http://down.111cn.net/down/code/php/qitayuanma/2010/1220/22333.html

语法
mail(to,subject,message,headers,parameters)参数 描述
to 必需。规定 email 接收者。
subject 必需。规定 email 的主题。注释:该参数不能包含任何新行字符。
message 必需。定义要发送的消息。应使用 lf (n) 来分隔各行。
headers 可选。规定附加的标题,比如 from、cc 以及 bcc。

应当使用 crlf (rn) 分隔附加的标题。
 
parameters 可选。对邮件发送程序规定额外的参数。


*/
$to='nobody@example.com';        //定义邮箱地址
$subject='mail';           //定义发送邮件的主题
$message='hello,php';         //定义邮件主体内容
$headers='from:webmaster@example.com'."rn".
'reply-to:webmaster@example.com'."rn".
 'x-mailer:php/'.phpversion();        //定义附加信息
mail($to,$subject,$message,$headers);      //发送邮件
?>
<?php
//发送html格式的邮件例子
$to='test@example.com'.',';
$to.='test1@example.com';        //定义多个收件人地址
$subject='mailhtml';          //定义邮件标题
//下面是邮件的html代码
$message='
<html>
<head>
<title>birthday reminders for august</title>
</head>
<body>
<p>here are the birthdays upcoming in august!</p>
<table>
  <tr>
    <th>person</th><th>day</th><th>month</th><th>year</th>
  </tr>
  <tr>
    <td>joe</td><td>3rd</td><td>august</td><td>1970</td>
  </tr>
  <tr>
    <td>sally</td><td>17th</td><td>august</td><td>1973</td>
  </tr>
</table>
</body>
</html>
';
//发送http请求
$headers='mime-version:1.0'."rn";        //定义附加信息
$headers.='content-type:text/html;charset=iso-8856-1'."rn";
$headers.='to:mary<mary@example.com>,kelly<kelly@example.com>'."rn";
$headers.='from:birthday reminder<birthday@example.com>'."rn";
$headers.='cc:birthdayarchive@example.com'."rn";
$headers.='bcc:birthdaycheck@example.com'."rn";
mail($to,$subject,$message,$headers);       //执行发送操作

/*

注释:php 需要一个已安装且正在运行的邮件系统,以便使邮件函数可用。所用的程序通过在 php.ini 文件中的配置设置进行定义

*/

不需要邮件服务器,不使用mail内置函数,一个类就搞定,利用php教程mailer类我写了一个自定义函数 sendmail() ,very实用!

以前也在几个php论坛上发表过这个发邮件的函数,今天再发,因为today要附上使用例子,如果你还不会用,那就要补补php基础课了。

  1.准备文件 sendmail.class.php文件、phpmailer类     下载  

2.下载后,解压 phpmailer.rar 到服务器的任何目录下

3.打开 sendmail.class.php ,修改如下(浅黄色部分是必须 要修改的变量值)

 // 以下 5 个变量值必须据实修改
 $host     = '61.183.41.172';
 $username = 'admin@php95.com';
 $password = "******"     
 $from     = 'admin@php95.com';   
 $fromname = '天马博客';  

// 先设置 $to $subject $content 这三个变量的值,再调用 sendmail 函数来发送邮件
$to = 'nt2030@qq.com';
$subject = '测试phpmailer类发送邮件';
$content = '测试phpmailer类发送邮件';
sendmail($to,$subject,$content);

4.修改 sendmail.class.php 完毕后,运行它..

你的邮件是否发送成功?

天马测试本代码,is ok,见证:

 点击查看原图

[!--infotagslink--]

相关文章

  • 分享一段php获取linux服务器状态的代码

    简单的php获取linux服务器状态的代码,不多说-直接上函数:复制代码 代码如下:function get_used_status(){ $fp = popen('top -b -n 2 | grep -E "^(Cpu|Mem|Tasks)"',"r");//获取某一时刻系统cpu和内存使用情况 $rs =...2014-05-31
  • NodeJS实现阿里大鱼短信通知发送

    本文给大家介绍的是nodejs实现使用阿里大鱼短信API发送消息的方法和代码,有需要的小伙伴可以参考下。...2016-01-20
  • PHP测试成功的邮件发送案例

    mail()函数的作用:连接到邮件服务器,利用smtp协议,与该服务器交互并投邮件。注意:1、mail函数不支持esmtp协议,---即,只能直投,不能登陆2、由上条,我们只能直投至最终的收件服务器地址.而该地址,又是在PHP.ini中指定的,所...2015-10-30
  • Springboot+TCP监听服务器搭建过程图解

    这篇文章主要介绍了Springboot+TCP监听服务器搭建过程,本文通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-10-28
  • 服务器 UDP端口占用几千个的解决办法

    前一段时间使用NetStat命令查看服务器端口时,发现服务器udp端口开放了好多,最少在1000个以上,当时事情比较多,没有管它,今天终于有点时间,仔细检查了一下,排除了这个问题. ...2016-01-27
  • php邮件发送的两种方式

    这篇文章研究的主要内容就是使用PHP来发送电子邮件,总结为以下两种方法:一、使用PHP内置的mail()函数<&#63;php $to = "test@163.com"; //收件人 $subject = "Test"; //主题 $message = "This is a test mail!"; //正文...2015-10-30
  • PHP连接公司内部服务器的MYSQL数据库的简单实例

    “主机,用户名,密码”得到连接、“数据库,sql,连接”得到结果,最后是结果的处理显示。当然,数据库连接是扩展库为我们完成的,我们能做的仅仅是处理结果而已。...2013-09-29
  • c# 实现发送邮件的功能

    这篇文章主要介绍了c# 如何实现发送邮件的功能,文中示例代码非常详细,帮助大家更好的理解和学习,感兴趣的朋友可以了解下...2020-07-07
  • 解决HttpPost+json请求---服务器中文乱码及其他问题

    这篇文章主要介绍了解决HttpPost+json请求---服务器中文乱码及其他问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-01-22
  • php邮件发送的两种方式

    这篇文章研究的主要内容就是使用PHP来发送电子邮件,总结为以下两种方法:一、使用PHP内置的mail()函数<&#63;php $to = "test@163.com"; //收件人 $subject = "Test"; //主题 $message = "This is a test mail!"; //正文...2015-10-30
  • python实现企业微信定时发送文本消息的实例代码

    这篇文章主要介绍了python实现企业微信定时发送文本消息的实例代码,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-11-25
  • Hyper-V尝试连接到服务器出错无效类的解决方法

    这篇文章主要介绍了Hyper-V尝试连接到服务器出错无效类的解决方法,需要的朋友可以参考下...2016-09-28
  • c#使用netmail方式发送邮件示例

    这篇文章主要介绍了c#使用netmail方式发送邮件的示例,大家参考使用吧...2020-06-25
  • PHP测试成功的邮件发送案例

    mail()函数的作用:连接到邮件服务器,利用smtp协议,与该服务器交互并投邮件。注意:1、mail函数不支持esmtp协议,---即,只能直投,不能登陆2、由上条,我们只能直投至最终的收件服务器地址.而该地址,又是在PHP.ini中指定的,所...2015-10-30
  • mac使用Shell(终端)SSH连接远程服务器的方法

    这篇文章主要介绍了mac使用Shell(终端)SSH连接远程服务器的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-07-11
  • js实现上传图片到服务器

    这篇文章主要为大家详细介绍了js实现上传图片到服务器,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-04-11
  • PHPMailer在SAE上无法发送邮件的解决方法

    PHPMailer在SAE上无法发送邮件怎么回事呢,我们以前在php5.2.7版本中使用了PHPMailer是可以发,但移到sae中发现无法发邮件了,那么此问题如何解决 在SAE上直接用5.2.7...2016-11-25
  • c# HttpWebRequest通过代理服务器抓取网页内容应用介绍

    在C#项目开发过程中可能会有些特殊的需求比如:用HttpWebRequest通过代理服务器验证后抓取网页内容,要想实现此方法并不容易,本文整理了一下,有需求的朋友可以参考下...2020-06-25
  • uploader秒传图片到服务器完整代码

    这篇文章主要为大家详细介绍了uploader秒传图片到服务器的完整代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2017-04-27
  • Linux环境下nginx搭建简易图片服务器

    这篇文章主要介绍了Linux环境下nginx搭建简易图片服务器,需要的朋友可以参考下...2016-01-27