Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?php
  2.     require_once('./phpmailer/PHPMailerAutoload.php');
  3.    
  4.    
  5.     $mail= new PHPMailer();                          //建立新物件
  6.     $mail->IsSMTP();                                    //設定使用SMTP方式寄信
  7.     $mail->SMTPAuth = true;                        //設定SMTP需要驗證
  8.     $mail->SMTPSecure = "ssl";                    // Gmail的SMTP主機需要使用SSL連線
  9.     $mail->Host = "ssl://smtp.gmail.com";             //Gamil的SMTP主機
  10.     $mail->Port = 465;                                 //Gamil的SMTP主機的埠號(Gmail為465)。
  11.     $mail->CharSet = "utf-8";                       //郵件編碼
  12.     $mail->Username = "leo604leo604@gmail.com"; //Gamil帳號
  13.     $mail->Password = "";                 //Gmail密碼
  14.     $mail->From = "leo604leo604@gmail.com";        //寄件者信箱
  15.     $mail->FromName = "leo604leo604";                  //寄件者姓名
  16.     $mail->Subject ="Test"; //郵件標題
  17.     $mail->Body = "Test mail"; //郵件內容
  18.     $mail->IsHTML(true);                             //郵件內容為html
  19.     $mail->AddAddress("leo604leo604@gmail.com");            //收件者郵件及名稱
  20.     if(!$mail->Send()){
  21.         echo "Error: " . $mail->ErrorInfo;
  22.     }else{
  23.         echo "<b>感謝您的留言,您的建議是我們前進的動力。</b>";
  24.     }
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement