IsSMTP(); //設定使用SMTP方式寄信 $mail->SMTPAuth = true; //設定SMTP需要驗證 $mail->SMTPSecure = "ssl"; // Gmail的SMTP主機需要使用SSL連線 $mail->Host = "smtp.gmail.com"; //Gamil的SMTP主機 $mail->Port = 465; //Gamil的SMTP主機的SMTP埠位為465埠。 $mail->CharSet = "utf8"; //設定郵件編碼 $mail->Username = "XXXX@gmail.com"; //設定驗證帳號 (你的GMAIL帳號) $mail->Password = "XXXX"; //設定驗證密碼 (你的GMAIL密碼) $mailtype='Content-Type:text/html;charset=utf-8'; $mailFrom='prof.chwu@gmail.com'; $mailTo=$row_RecSendPass['m_email']; $mailCC=''; $mailBCC=''; $mailSubject="=?utf-8?B?".base64_encode("XXX會員系統密碼查詢")."?="; $mailContent = $row_RecSendPass['m_name'] . '您好,您的密碼為 ' . $_POST['m_passwd']; $mail->From = $mailFrom; //設定寄件者信箱 $mail->FromName = "寄件者: " . $mailFrom; //設定寄件者姓名 $mail->Subject = $mailSubject; //設定郵件標題 $maildata = "From:" . $mailFrom . "\r\n"; if ($mailCC != '') { $maildata .= "CC:$mailCC\r\n"; } if ($mailBCC != '') { $maildata .= "BCC:$mailBCC\r\n"; } $maildata .= "$mailtype"; //mail($mailTo,$mailSubject,$mailContent,$maildata); $mail->Subject = $mailSubject; //設定郵件標題 $EmailBody = nl2br($mailContent); $mail->Body = $EmailBody; //設定郵件內容 $mail->IsHTML(true); //設定郵件內容為HTML $mail->AddAddress($mailTo, $row_RecSendPass['m_name']); //設定收件者郵件及名稱 if ($mailCC != '') { $mail->AddCC($mailCC); // 設定CC } if ($mailBCC != '') { $mail->AAddBCC($mailBCC); //設定BCC } if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?>