茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1729118 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_2543266.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2010/3/23 8:31:57

PHP雖然有內建的Mail函式功能,但勢必鏡還是比較簡易。

所以偉大的SourceForge就有強者幫我們做出了一個更好用的
PHPMailer

這裡先來看一下別人的安裝範例與簡單實例。

PHPMailer安裝及簡單實例



PHPMailer是一個用PHP寫的用於郵件發送的類,有點像Jmail,相信很多新手和我一樣,開始很茫然,不知道怎麼安裝,查找了一下,發現這方面的資料真的少之又少,一個文章被轉載千百次,一搜索全是同一個內容,真不知道說什麼好,其實打開安裝裡的readme就一目瞭然了,閒話少說,安裝其實很簡單。



打開你電腦裡的PHP.INI文件,找到如下位置,添加紅線部分的內容,路徑就是你PHPMailer存放的位置:





attachments/200611/29_150901_phpmailer.jpg




保存,重啟apache.



然後借用readme裡的一個例子,稍微改一下就可以用了,由於只做最簡單的測試,很多東西我註釋掉了。



send.php

<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$address = $_POST['address'];
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mail.songzi.org"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "phpmailer@songzi.org"; // SMTP username
$mail->Password = "******"; // SMTP password
$mail->From = "phpmailer@songzi.org";
$mail->FromName = "songzi";
$mail->AddAddress("$address", "");
//$mail->AddAddress(""); // name is optional
//$mail->AddReplyTo("", "");
//$mail->WordWrap = 50; // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
//$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "PHPMailer測試郵件";
$mail->Body = "Hello,這是松子的測試郵件";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
 echo "Message could not be sent. <p>";
 echo "Mailer Error: " . $mail->ErrorInfo;
 exit;
}
echo "Message has been sent";
	?>






test.php
	<html>
		<body><h3>phpmailer Unit Test</h3>請你輸入
			<font color="#FF6666">收信
			</font>的郵箱地址:
			<form name="phpmailer" action="send.php" method="post">
				<input type="hidden" name="submitted" value="1"/>郵箱地址:
				<input type="text" size="50" name="address" />
				<br/>
				<input type="submit" value="發送"/>
			</form>
		</body>
	</html>


測試地址:
http://disk.songzi.org/test/phpmailer/test.php
[Last Modified By songzi, at 2006-11-29 15:18:46]



原文出處:
PHPMailer安装及简单实例 - Songzi Blog
內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|