ThinkPHP邮件发送S(Smtp + Mail + phpmailer)

  三种邮件发送介绍:(Smtp,Mail以及phpmailer)ThinkPhp 框架下开发。

  邮件发送配置先前准备(用该账号做测试用):(这里用新浪邮箱服务器)将自己的新浪邮箱开通 POP3/SMTP服务:

新浪邮箱中  :设置->账户下面的 POP3/SMTP服务 选择开通(然后一步一步完成开通)。

 客户端html代码:

 1 <body>
 2     <!--<h1>发送信息测试</h1>-->
 3     <div>请输入发送地址(1):<input id="adds" type="text" style="width:180px;" /></div>
 4     <div>主题:<input id="title" type="text" style="width:100px;" /></div>
 5     <div style="width:600px;vertical-align:top;">
 6         发送信息:
 7         <textarea id="msgbody" property="请输入需要发送的信息..." style="width:180px;height:100px;"></textarea>
 8     </div>
 9     <div>
10         <input type="button" value="发送1" onclick="sendmsg()" />
11     </div>
12 <body>

js:

 1  <script>
 2         function sendmsg() {
 3             var id = document.getElementById("adds").value;
 4             var msg = document.getElementById("msgbody").value;
 5             var title = document.getElementById("title").value;
 6             var par = /^[a-zA-Z0-9_+.-]+\@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9]{2,4}$/;
 7
 8             if (id == "") {
 9                 alert("输入发送地址");
10                 return;
11             } else if (!par.exec(id)) {
12                 alert("填写地址错误!");
13                 return;
14             }
15             showloading();
16             $.post(‘__ROOT__/Home/SendEmail/sendMails‘, { email: id,title:title, msg: msg }, function (data) {
17                 if (data.status == 1) {
18                     hideloading();
19                    // try {
20                         alert("信息发送成功!");
21                         alert(data.data);
22                    // } catch (e) {
23                      //   alert(e.message);
24                    // }
25                 } else {
26                     hideloading();
27                     alert("未知错误!");
28                 }
29             }, ‘json‘);
30         }
31 </script>

 第一种:Smtp(PHP)。

  1:在ThinkPHP/LibraryLibrary文件夹下新建一个文件夹  HomeClass,在HomeClass 文件夹下新建一个类 命名为:smtp.class.php。(网上能找到的)

  1 <?php
  2 class smtp
  3 {
  4     /* Public Variables */
  5     var $smtp_port;
  6     var $time_out;
  7     var $host_name;
  8     var $log_file;
  9     var $relay_host;
 10     var $debug;
 11     var $auth;
 12     var $user;
 13     var $pass;
 14
 15     /* Private Variables */
 16     var $sock;
 17
 18     /* Constractor */
 19
 20     function smtp($relay_host = "", $smtp_port = 25,$auth = false,$user,$pass)
 21     {
 22         $this->debug = FALSE;
 23         $this->smtp_port = $smtp_port;
 24         $this->relay_host = $relay_host;
 25         $this->time_out = 30; //is used in fsockopen()
 26
 27         #
 28
 29         $this->auth = $auth;//auth
 30         $this->user = $user;
 31         $this->pass = $pass;
 32
 33         #
 34
 35         $this->host_name = "localhost"; //is used in HELO command
 36         $this->log_file = "";
 37         $this->sock = FALSE;
 38     }
 39     /* Main Function */
 40
 41     function sendmail($to, $from, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "")
 42     {
 43         $mail_from = $this->get_address($this->strip_comment($from));
 44         $body = ereg_replace("(^|(\r\n))(\.)", "\1.\3", $body);
 45         $header = "MIME-Version:1.0\r\n";
 46
 47         if($mailtype=="HTML"){
 48             $header .= "Content-Type:text/html\r\n";
 49         }
 50
 51         $header .= "To: ".$to."\r\n";
 52
 53         if ($cc != "") {
 54             $header .= "Cc: ".$cc."\r\n";
 55         }
 56
 57         $header .= "From: 报名邮件.<".$from.">\r\n";
 58         $header .= "Subject: ".$subject."\r\n";
 59         $header .= $additional_headers;
 60         $header .= "Date: ".date("r")."\r\n";
 61         $header .= "X-Mailer:By Redhat (PHP/".phpversion().")\r\n";
 62         $utfheader=iconv("UTF-8","GB2312",$header);
 63         list($msec, $sec) = explode(" ", microtime());
 64
 65         $header .= "Message-ID: <".date("YmdHis", $sec).".".($msec*1000000).".".$mail_from.">\r\n";
 66
 67         $TO = explode(",", $this->strip_comment($to));
 68
 69         if ($cc != "") {
 70             $TO = array_merge($TO, explode(",", $this->strip_comment($cc)));
 71         }
 72
 73
 74         if ($bcc != "") {
 75             $TO = array_merge($TO, explode(",", $this->strip_comment($bcc)));
 76         }
 77
 78         $sent = TRUE;
 79
 80         foreach ($TO as $rcpt_to) {
 81             $rcpt_to = $this->get_address($rcpt_to);
 82
 83             if (!$this->smtp_sockopen($rcpt_to)) {
 84                 $this->log_write("Error: Cannot send email to ".$rcpt_to."\n");
 85                 $sent = FALSE;
 86                 continue;
 87             }
 88
 89             if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $utfheader, $body)) {
 90                 $this->log_write("E-mail has been sent to <".$rcpt_to.">\n");
 91             } else {
 92                 $this->log_write("Error: Cannot send email to <".$rcpt_to.">\n");
 93                 $sent = FALSE;
 94             }
 95
 96             fclose($this->sock);
 97
 98             $this->log_write("Disconnected from remote host\n");
 99         }
100         return $sent;
101     }
102 /* Private Functions */
103     function smtp_send($helo, $from, $to, $header, $body = "")
104     {
105         if (!$this->smtp_putcmd("HELO", $helo)) {
106
107             return $this->smtp_error("sending HELO command");
108         }
109
110         #auth
111
112         if($this->auth){
113             if (!$this->smtp_putcmd("AUTH LOGIN", base64_encode($this->user))) {
114                 return $this->smtp_error("sending HELO command");
115             }
116
117             if (!$this->smtp_putcmd("", base64_encode($this->pass))) {
118                 return $this->smtp_error("sending HELO command");
119             }
120         }
121
122         #
123
124         if (!$this->smtp_putcmd("MAIL", "FROM:<".$from.">")) {
125             return $this->smtp_error("sending MAIL FROM command");
126         }
127
128         if (!$this->smtp_putcmd("RCPT", "TO:<".$to.">")) {
129             return $this->smtp_error("sending RCPT TO command");
130         }
131
132         if (!$this->smtp_putcmd("DATA")) {
133             return $this->smtp_error("sending DATA command");
134         }
135         if (!$this->smtp_message($header, $body)) {
136             return $this->smtp_error("sending message");
137         }
138         if (!$this->smtp_eom()) {
139             return $this->smtp_error("sending <CR><LF>.<CR><LF> [EOM]");
140         }
141         if (!$this->smtp_putcmd("QUIT")) {
142             return $this->smtp_error("sending QUIT command");
143         }
144         return TRUE;
145     }
146
147     function smtp_sockopen($address)
148     {
149         if ($this->relay_host == "") {
150             return $this->smtp_sockopen_mx($address);
151         } else {
152             return $this->smtp_sockopen_relay();
153         }
154     }
155     function smtp_sockopen_relay()
156     {
157         $this->log_write("Trying to ".$this->relay_host.":".$this->smtp_port."\n");
158         $this->sock = @fsockopen($this->relay_host, $this->smtp_port, $errno, $errstr, $this->time_out);
159         if (!($this->sock && $this->smtp_ok())) {
160             $this->log_write("Error: Cannot connenct to relay host ".$this->relay_host."\n");
161             $this->log_write("Error: ".$errstr." (".$errno.")\n");
162             return FALSE;
163         }
164         $this->log_write("Connected to relay host ".$this->relay_host."\n");
165         return TRUE;
166     }
167
168     function smtp_sockopen_mx($address)
169     {
170         $domain = ereg_replace("^[email protected]([^@]+)$", "\1", $address);
171         if ([email protected]($domain, $MXHOSTS)) {
172             $this->log_write("Error: Cannot resolve MX \"".$domain."\"\n");
173             return FALSE;
174         }
175         foreach ($MXHOSTS as $host) {
176             $this->log_write("Trying to ".$host.":".$this->smtp_port."\n");
177             $this->sock = @fsockopen($host, $this->smtp_port, $errno, $errstr, $this->time_out);
178             if (!($this->sock && $this->smtp_ok())) {
179                 $this->log_write("Warning: Cannot connect to mx host ".$host."\n");
180                 $this->log_write("Error: ".$errstr." (".$errno.")\n");
181                 continue;
182             }
183             $this->log_write("Connected to mx host ".$host."\n");
184             return TRUE;
185         }
186         $this->log_write("Error: Cannot connect to any mx hosts (".implode(", ", $MXHOSTS).")\n");
187         return FALSE;
188     }
189
190     function smtp_message($header, $body)
191     {
192         fputs($this->sock, $header."\r\n".$body);
193         $this->smtp_debug("> ".str_replace("\r\n", "\n"."> ", $header."\n> ".$body."\n> "));
194         return TRUE;
195     }
196
197     function smtp_eom()
198     {
199         fputs($this->sock, "\r\n.\r\n");
200         $this->smtp_debug(". [EOM]\n");
201         return $this->smtp_ok();
202     }
203
204     function smtp_ok()
205     {
206         $response = str_replace("\r\n", "", fgets($this->sock, 512));
207         $this->smtp_debug($response."\n");
208         if (!ereg("^[23]", $response)) {
209             fputs($this->sock, "QUIT\r\n");
210             fgets($this->sock, 512);
211             $this->log_write("Error: Remote host returned \"".$response."\"\n");
212             return FALSE;
213         }
214         return TRUE;
215     }
216
217     function smtp_putcmd($cmd, $arg = "")
218     {
219         if ($arg != "") {
220             if($cmd=="") $cmd = $arg;
221             else $cmd = $cmd." ".$arg;
222         }
223         fputs($this->sock, $cmd."\r\n");
224         $this->smtp_debug("> ".$cmd."\n");
225         return $this->smtp_ok();
226     }
227
228     function smtp_error($string)
229     {
230         $this->log_write("Error: Error occurred while ".$string.".\n");
231         return FALSE;
232     }
233
234     function log_write($message)
235     {
236         $this->smtp_debug($message);
237         if ($this->log_file == "") {
238             return TRUE;
239         }
240         $message = date("M d H:i:s ").get_current_user()."[".getmypid()."]: ".$message;
241         if ([email protected]file_exists($this->log_file) || !($fp = @fopen($this->log_file, "a"))) {
242             $this->smtp_debug("Warning: Cannot open log file \"".$this->log_file."\"\n");
243             return FALSE;;
244         }
245         flock($fp, LOCK_EX);
246         fputs($fp, $message);
247         fclose($fp);
248         return TRUE;
249     }
250
251     function strip_comment($address)
252     {
253         $comment = "\([^()]*\)";
254         while (ereg($comment, $address)) {
255             $address = ereg_replace($comment, "", $address);
256         }
257         return $address;
258     }
259
260     function get_address($address)
261     {
262         $address = ereg_replace("([ \t\r\n])+", "", $address);
263         $address = ereg_replace("^.*<(.+)>.*$", "\1", $address);
264         return $address;
265     }
266     function smtp_debug($message)
267     {
268         if ($this->debug) {
269         echo $message;
270         }
271     }
272 }
273 ?>

  2:提交到的后台控制器  SendEmailController.class.php

 1 public function sendmsg(){
 2         $email = I ( ‘post.email‘ );
 3         $msgs = I(‘post.msg‘);
 4         $title=I(‘post.title‘);
 5
 6         import("HomeClass.smtp");//引用发送邮件类
 7
 8         $smtpserver     =     "smtp.sina.cn";//SMTP服务器
 9         $smtpserverport =    25;//SMTP服务器端口
10         $smtpusermail     =     "******@sina.cn";//SMTP服务器的用户邮箱
11         $smtpuser         =     "****";//SMTP服务器的用户帐号
12         $smtppass         =     "*****";//SMTP服务器的用户密码
13
14         $smtpemailto     =     $email;//发送给谁
15         $mailsubject     =     $title;//邮件主题
16         $mailtime        =    date("Y-m-d H:i:s");
17         $mailbody         =     $msgs;//邮件内容
18
19         $utfmailbody    =    iconv("UTF-8","GB2312",$mailbody);//转换邮件编码
20         $mailtype         =     "TXT";//邮件格式(HTML/TXT),TXT为文本邮件
21
22         $smtp = new \smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//这里面的一个true是表示使用身份验证,否则不使用身份验证.
23         $smtp->debug = FALSE;//是否显示发送的调试信息 FALSE or TRUE
24
25         $datas = $smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $utfmailbody, $mailtype);
26
27         $this->ajaxReturn ( array (
28                 ‘data‘ => $datas,
29                 ‘status‘ => 1
30         ) );
31     }

其中:$smtpusermail 为你的新浪邮箱账号,$smtpuser 为你新浪邮箱账号(邮箱去掉@sina.com),$smtppass  为你的邮箱密码。第一种邮件发送搞定,你可以发送邮件去另一个邮箱了!!!

第二种:Mail(ThinkPHP)。

1:配置服务器邮箱:在 Application/conf/config.php 文件中添加邮箱配置:

 1 ‘THINK_EMAIL‘ => array (
 2
 3                 ‘SMTP_HOST‘ => ‘smtp.sina.cn‘,
 4                 ‘SMTP_PORT‘ => ‘25‘,
 5                 ‘SMTP_USER‘ => ‘******@sina.cn‘, // SMTP服务器用户名
 6                 ‘SMTP_PASS‘ => ‘******‘, // SMTP服务器密码
 7                 ‘FROM_EMAIL‘ => ‘******@sina.cn‘, // 发件人EMAIL
 8                 ‘FROM_NAME‘ => ‘****‘, // 发件人名称
 9                 ‘REPLY_EMAIL‘ => ‘‘, // 回复EMAIL(留空则为发件人EMAIL)
10
11                 ‘REPLY_NAME‘ => ‘‘
12         ),

SMTP_USER  与 FROM_EMAIL 可为同一 邮箱地址。

2:在 HomeClass  文件夹下 新建一个类:Mail.class.php:(网上能找到)

 1 <?php
 2
 3 namespace HomeClass;
 4
 5 class Mail {
 6     /**
 7      * 系统邮件发送函数
 8      *
 9      * @param string $to
10      *            接收邮件者邮箱
11      * @param string $name
12      *            接收邮件者名称
13      * @param string $subject
14      *            邮件主题
15      * @param string $body
16      *            邮件内容
17      * @param string $attachment
18      *            附件列表
19      * @return boolean
20      */
21     function sendMail($to, $name, $subject = ‘‘, $body = ‘‘, $attachment = null) {
22         $config = C ( ‘THINK_EMAIL‘ );
23         vendor ( ‘PHPMailer.class#phpmailer‘ ); // 从PHPMailer目录导class.phpmailer.php类文件
24         $mail = new \PHPMailer (); // PHPMailer对象
25         $mail->CharSet = ‘UTF-8‘; // 设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
26
27         //$mail->AddAddress($address);//添加联系人
28
29         $mail->IsSMTP (); // 设定使用SMTP服务
30         $mail->SMTPDebug = 0; // 关闭SMTP调试功能
31                               // 1 = errors and messages
32                               // 2 = messages only
33         $mail->SMTPAuth = true; // 启用 SMTP 验证功能
34         //$mail->SMTPSecure = ‘ssl‘; // 使用安全协议
35         $mail->Host = $config [‘SMTP_HOST‘]; // SMTP 服务器
36         $mail->Port = $config [‘SMTP_PORT‘]; // SMTP服务器的端口号
37         $mail->Username = $config [‘SMTP_USER‘]; // SMTP服务器用户名
38         $mail->Password = $config [‘SMTP_PASS‘]; // SMTP服务器密码
39         $mail->SetFrom ( $config [‘FROM_EMAIL‘], $config [‘FROM_NAME‘] );
40         $replyEmail = $config [‘REPLY_EMAIL‘] ? $config [‘REPLY_EMAIL‘] : $config [‘FROM_EMAIL‘];
41         $replyName = $config [‘REPLY_NAME‘] ? $config [‘REPLY_NAME‘] : $config [‘FROM_NAME‘];
42         $mail->AddReplyTo ( $replyEmail, $replyName );
43         $mail->Subject = $subject;
44
45         $mail->MsgHTML ( $body );
46         $mail->AddAddress ( $to, ‘亲‘ );
47         if (is_array ( $attachment )) { // 添加附件
48             foreach ( $attachment as $file ) {
49                 is_file ( $file ) && $mail->AddAttachment ( $file );
50             }
51         }
52         return $mail->Send () ? true : $mail->ErrorInfo;
53     }
54 }

3:将前面JS代码的post提交链接改为 __ROOT__/Home/SendEmail/sendMails2,在刚才的控制器 SendEmailController.class.php 中添加一个方法: sendMail2().

 1 public function sendMails2(){
 2         $email = I ( ‘post.email‘ );
 3         $msgs = I(‘post.msg‘);
 4         $title=I(‘post.title‘);
 5
 6         $msg = \HomeClass\Mail::sendMail ( $email, $email, $title, $msgs );
 7
 8         $this->ajaxReturn ( array (
 9                 ‘data‘ => $msg,
10                 ‘status‘ => 1
11         ) );
12     }

第三种:PHPMailer(ThinkPHP)

  1:看看ThinkPHP框架的 Library/Vendor 文件夹下是否存在 文件夹  PHPMailer,如果不存在,则在网上找个加入在该文件夹下。

  2:将前面的JS提交链接改为 __ROOT__/Home/SendEmail/sendMails3 ,在控制器里添加方法 sendMail3():

 1 public function sendmsg3($sendto_email, $user_name=‘‘, $subject, $bodyurl)
 2     {
 3
 4         $email = I ( ‘post.email‘ );
 5         $title=I(‘post.title‘);
 6         $msgs = I(‘post.msg‘);
 7
 8         vendor ( ‘PHPMailer.class#phpmailer‘ );
 9         $mail = new \PHPMailer();
10         $mail->IsSMTP();                  // send via SMTP
11
12         $mail->Host = "smtp.sina.cn"; // SMTP 服务器
13         $mail->Port = 25; // SMTP服务器的端口号
14         $mail->SMTPAuth = true;           // turn on SMTP authentication
15         $mail->Username = "*****@sina.cn"; // SMTP服务器用户名
16         $mail->Password = "******"; // SMTP服务器密码
17
18         $mail->From = "*******@sina.cn";      // 发件人邮箱
19         //$mail->FromName = "****";;  // 发件人
20
21         $mail->CharSet = "utf-8";   // 这里指定字符集!
22         $mail->Encoding = "base64";
23
24         if($user_name == ‘‘)
25         {
26             $user_name=$sendto_email;
27         }
28         $mail->AddAddress($sendto_email,$sendto_email);  // 收件人邮箱和姓名
29
30         //$mail->WordWrap = 50; // set word wrap 换行字数
31         //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment 附件
32         //$mail->AddAttachment("/tmp/image.jpg", "new.jpg");
33
34         $mail->IsHTML(true);  // send as HTML
35         // 邮件主题
36         $mail->Subject = $subject;
37
38         //$urls=urlencode($bodyurl);
39         $mail->Body="Hi,欢迎注册!";
40         $mail->AltBody = "text/html";
41
42         if (!$mail->Send())
43         {
44             $mail->ClearAddresses();
45             return "邮件错误信息: " . $mail->ErrorInfo;
46             exit;
47         }
48         else
49         {
50             $mail->ClearAddresses();
51             // $this->assign(‘waitSecond‘, 6);
52             //            $this->success("注册成功,系统已经向您的邮箱:{$sendto_email}发送了一封激活邮件!请您尽快激活~~<br />");
53             //$this->redirect(‘sendhtml‘, array(‘send‘ => 5,‘email‘=>$sendto_email));
54             return "亲!已经向您的邮箱:{$sendto_email}发送了一封激活邮件!请您尽快激活~~";
55         }
56     }

  现在可以给另一个邮箱发送邮件了!!!

发送邮件页面:

        

    接收到的邮件:

      

注:以上配置我只在给新浪邮箱发送邮件时成功,给QQ邮箱发送邮件时都已失败而告终,还搞不懂是为啥??

ThinkPHP官网邮件发送:  http://www.thinkphp.cn/code/32.html

  PHP邮件发送: http://www.oschina.net/code/snippet_1182150_25127

时间: 2025-01-02 08:58:46

ThinkPHP邮件发送S(Smtp + Mail + phpmailer)的相关文章

thinkphp 邮件发送

最近项目上要求,要做个邮件发送的功能,因为用到的框架是ThinkPHP,于是就自己整理一下. 引入class.phpmailer.php,大家可以去这个链接去下载: http://pan.baidu.com/s/1eRb40iY 界面demo,大家可以自行丰富: 在Home文件夹中建立文件Lib,导入下载的文件夹. 在controller层中引入class.phpmailer.php 引入文件并实例化: require_once(dirname(__FILE__).'/../Lib/mail/c

Zend_Mail 邮件发送(SMTP方式)

Zend_Mail邮件发送 转载请注明出处,尊重原创:http://blog.csdn.net/a437629292/article/details/41700009 一. 邮件发送方式: 1.直接邮件服务器发送: 直接使用邮件服务器发送,也就是php程序所在服务器上本来就是邮件服务器(即配置成SMTP邮件服务器),并且发送到的对方也必须是邮件服务器,比如QQ邮箱,163邮箱等等,他们直接也是使用SMTP协议 2. 委托其他邮件服务器发送: php程序委托其他邮件服务器发送邮件(必须条件:该服务

Drupal 7 电子邮件的发送设置 SMTP, Mail System, Mime Mail

虽然Drupal自带发送email功能,但是很多服务器需要SMTP验证,这个时候就需要安装 SMTP 模块. 激活 SMTP 模块 进入配置 admin/config/system/smtp 在 Turn this module on or off  选择 on 填写 SMTP SERVER SETTINGS 中相关信息 (如果你的服务器在godaddy,只要在 SMTP server 填写 relay-hosting.secureserver.net 就可以.其他都用默认配置) 你可以在 SE

配置Mail邮件发送

tail -5 /etc/mail.rc  #加上这几行,代表用我这个账号登陆邮件去发送消息 set [email protected] set smtp=smtp.126.com set [email protected] set smtp-auth-password=123456 set smtp-auth=login 发送邮件命令 1.使用管道进行邮件发送 echo "hello" | mail -s "Hello from mzone.cc by pipe"

Linux mail 邮件发送

Linux mail 邮件介绍 在Linux系统下我们可以通过"mail"命令,发送邮件,在运维中通常我们它来实现邮件告警. 安装 yum install -y sendmail.i686 yum install -ymailx.i686 启动:service sendmail start netstat -lnp | grep :25 tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1102/master tcp 0 0 ::1:25 :::* LISTE

学习笔记之邮件发送篇

用脚本语言发送邮件是系统管理员必备技能 对系统定期检查或者当服务器受到攻击时生成文档和报表. 发布这些文档最快速有效的方法就是发送邮件. python中email模块使得处理邮件变得比较简单 发送邮件主要用到了smtplib和email两个模块,这里首先就两个模块进行一下简单的介绍: 本段摘录于    http://www.cnblogs.com/xiaowuyi/archive/2012/03/17/2404015.html 1.smtplib模块 smtplib.SMTP([host[, p

JavaMail如何保证邮件发送成功

使用过JavaMail的api发送邮件的人可能会有这样一个疑惑:我如何知道我调用该api发送的邮件是否成功呢?一般的开放的api给我们调用都会有个返回值或者状态码,来告诉我们执行成功与否.但是JavaMail却没有提供这样一个返回值. 所以在调用JavaMail发送邮件的时候,我们只能通过catch异常的方式来判断邮件是否发送成功.我们认为只要没有异常发生,那么邮件就能发送成功.那么我们就来分析一下JavaMail为什么没有提供返回值,和通过异常判断邮件发送成功状态是否靠谱. JavaMail发

C# 实现邮件发送功能

/// <summary> /// 发送邮件 /// </summary> /// <param name="from">发件人邮箱</param> /// <param name="fromname">发件人姓名</param> /// <param name="to">收件人地址</param> /// <param name="s

C#邮件发送(最坑爹的邮箱-QQ邮箱)---转发(SmallFlyElephant)

C#邮件发送(最坑爹的邮箱-QQ邮箱) 最近工作挺清闲的,有空的时候陪妹子出去玩玩,自己看看小说,看看电影,日子过的挺欢乐的,这个星期幡然悔悟,代码才是我的最爱,做点小东西,就写个邮件发送程序.说的邮件发送相信工作过基本上都会用到过,用户注册完之后发个验证邮件过去验证一下,改密码的时候邮箱验证一下,用户对网站体验如何发个邮件调查一下,网站最近最热的内容发个邮件推送一下,好吧,有点啰嗦.正文开始吧: SMTP定义 简单邮件传输协议 (Simple Mail Transfer Protocol, S