<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<?php
require("PHPMailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "mygmail@gmail.com"; // SMTP username
$mail->Password = "MY_PASSWORD_GOES_HERE"; // SMTP password
$webmaster_email = "username@doamin.com"; //Reply to this email ID
$email="some1@mail.com"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->Subject = "This is the subject";
$mail->Body = "Hi"
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}
else{
echo "Message has been sent";
}
?>
这是我发送电子邮件的 php 脚本。它非常简单,取自 PHPMailer 主页。我正在尝试从为我的网页提供服务的 Apache 服务器提供此服务。当我尝试访问脚本时出现错误:加载页面失败。
这里的php代码有什么问题吗?我也修改了我的 php.ini 文件,所以一切似乎都是必须的,但它不起作用。