在本機用phpmailer發送郵件有關問題

來源:互聯網
上載者:User
在本機用phpmailer發送郵件問題
我在本機上用的WampServer Version 2.1版本作為php伺服器,來測試phpmailer發送郵件。我下載了最新的class.phpmailer.php和class.smtp.php檔案,建立了個php檔案phpmail.php來測試發送郵件功能,代碼如下:
require_once('class.phpmailer.php');
include("class.smtp.php");

$mail = new PHPMailer(); //建立郵件發送類
$address = $_POST['address'];
$mail->SMTPDebug=true ;
$mail->IsSMTP(); // 使用SMTP方式發送
$mail->CharSet = "UTF-8"; //chinese;
$mail->Host = "smtp.163.com"; // 局smtp伺服器
$mail->SMTPAuth = true; // 啟用SMTP驗證功能
$mail->Username = "cnmhg168"; // 使用者名稱(請填寫完整的email地址)
$mail->Password = "******"; // 密碼

$mail->From = "[email protected]"; //郵件寄件者email地址
$mail->FromName = "化工網";
$mail->AddAddress("[email protected]", "tttt");//收件者地址

//$mail->AddAttachment("/var/tmp/file.tar.gz"); // 添加附件
$mail->IsHTML(true); // set email format to HTML //是否使用HTML格式

$mail->Subject = "PHPMailer測試郵件"; //郵件標題
$mail->Body = "Hello,這是測試郵件,百度"; //郵件內容
$mail->AltBody = "from 火星"; //附加資訊,可以省略
//$mail->SMTPDebug;

if(!$mail->Send())
{
echo "郵件發送失敗.

";
echo "錯誤原因: " . $mail->ErrorInfo;
exit;
}

echo "郵件發送成功";


?>
使用者名稱和密碼沒問題,但是提示如下錯誤資訊,不知道哪裡有問題,求大家給解決下?


( ! ) Notice: Undefined index: address in D:\wamp\www\PHPMailer\phpmail.php on line 6
Call Stack
# Time Memory Function Location
1 0.0041 373128 {main}( ) ..\phpmail.php:0
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "220 163.com Anti-spam GT for Coremail System (163com[20121016]) "
SMTP -> get_lines(): $data is "220 163.com Anti-spam GT for Coremail System (163com[20121016]) "
SMTP -> FROM SERVER:220 163.com Anti-spam GT for Coremail System (163com[20121016])
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250-mail "
SMTP -> get_lines(): $data is "250-mail "
SMTP -> get_lines(): $data was "250-mail "
SMTP -> get_lines(): $str is "250-PIPELINING "
SMTP -> get_lines(): $data is "250-mail 250-PIPELINING "
SMTP -> get_lines(): $data was "250-mail 250-PIPELINING "
SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN "
SMTP -> get_lines(): $data is "250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN "
SMTP -> get_lines(): $data was "250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN "
SMTP -> get_lines(): $str is "250-AUTH=LOGIN PLAIN "
SMTP -> get_lines(): $data is "250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN "

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.