[請益] mail 寄不出去
板上有很多phpmailer的教學
但是我是用虛擬主機的 所以沒辦法裝的樣子
用 mail() 因為空間沒有SMTP
還有什麼方法嗎? 還是我的寫法有錯?
<?php
include("class.phpmailer.php");
include("class.smtp.php");
$name = $_POST['name'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$email = $_POST['mail'];
$top = $_POST['top'];
$msg = $_POST['msg'];
$msg = "$name<br>$phone<br>$address<br>$mail<br><br>$msg";
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server 非25
$mail->Username = "XXX"; // GMAIL username
$mail->Password = "XXXXX"; // GMAIL password
$mail->AddReplyTo($email,$name);
$mail->From = $name;
$mail->FromName = $name;
$mail->Subject = $top;
$mail->AddAddress("OOOOO","OOO");
$mail->CharSet = "utf-8";
$mail->Encoding = "base64";
$mail->Body = $msg;
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "
寄信成功!
";
}
echo $msg."<br>".$header;
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.111.76.71
噓
06/17 09:30, , 1F
06/17 09:30, 1F
→
06/17 19:38, , 2F
06/17 19:38, 2F
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章