Guest User

Untitled

a guest
Feb 20th, 2018
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <?php
  2. // 建立 PHPMailer 物件及設定 SMTP 登入資訊
  3. require("../phpMailer/class.phpmailer.php");
  4. $mail = new PHPMailer();
  5. $mail->IsSMTP(); // send via SMTP
  6.  
  7. $mail->Host = "remote.smtp.server"; // SMTP servers
  8. $mail->SMTPAuth = true; // turn on SMTP authentication
  9.  
  10. $mail->Username = "me@localhost"; // SMTP username
  11. $mail->Password = "123456"; // SMTP password
  12.  
  13. $mail->From = "myemail@localhost";
  14. $mail->FromName = "My Name";
  15. // 執行 $mail->AddAddress() 加入收件者,可以多個收件者
  16.  
  17. $mail->AddAddress("to@email.com","Josh Adams");
  18. $mail->AddAddress("to2@email.com"); // optional name
  19.  
  20. $mail->AddReplyTo("jyu@aemtechnology.com","AEM");
  21. $mail->WordWrap = 50; // set word wrap
  22. // 執行 $mail->AddAttachment() 加入附件,可以多個附件
  23.  
  24. $mail->AddAttachment("path_to/file"); // attachment
  25. $mail->AddAttachment("path_to_file2", "INF");
  26. // 電郵內容,以下為發送 HTML 格式的郵件
  27.  
  28. $mail->IsHTML(true); // send as HTML
  29. $mail->Subject = "testing email";
  30.  
  31. $mail->Body = "This is the <b>HTML body</b>";
  32. $mail->AltBody = "This is the text-only body";
  33. if(!$mail->Send())
  34. {
  35.  
  36. echo "Message was not sent <p>";
  37. echo "Mailer Error: " . $mail->ErrorInfo;
  38.  
  39. exit;
  40. }
  41. echo "Message has been sent";
  42. ?>
Add Comment
Please, Sign In to add comment