PHP编译器未连接HTML/PHP

PHP编译器未连接HTML/PHP,php,html,forms,email,Php,Html,Forms,Email,我正在尝试让我的HTML联系人表单与PHPMailer一起工作,但当我尝试发送消息时,我无法连接到服务器: 2017-06-15 10:39:15 SMTP错误:无法连接到服务器:(0)2017-06-15 10:39:15 SMTP connect()失败。邮件程序错误:SMTP连接()失败 我正在尝试连接到SiteGround SMTP服务器 表格编号: <form id="contact" action="mailer.php" method="post"> <d

我正在尝试让我的HTML联系人表单与PHPMailer一起工作,但当我尝试发送消息时,我无法连接到服务器:

2017-06-15 10:39:15 SMTP错误:无法连接到服务器:(0)2017-06-15 10:39:15 SMTP connect()失败。邮件程序错误:SMTP连接()失败

我正在尝试连接到SiteGround SMTP服务器

表格编号:

<form id="contact" action="mailer.php" method="post">
    <div class="left">
        <input type="text" placeholder="Name" required="required" name="name"/>
        <input type="email" placeholder="Email" required="required" name="email"/>
        <input type="text" placeholder="Subject" required="required" name="subject"/>
    </div>
    <div class="right">
        <textarea placeholder="Message" required="required" name="message"></textarea>
    </div>
    <div class="send-button cl">
        <button type="submit" name="submit">Send</button>
    </div>
</form>

发送
PHP代码:

//Creating the message
$message =
'Name:  '.$_POST['name'].'<br />
Subject:    '.$_POST['subject'].'<br />
Email:  '.$_POST['email'].'<br />
Message:    '.$_POST['message'].'
';

require 'phpmailer/PHPMailerAutoload.php';

// Instantiate Class
$mail = new PHPMailer();

// Set up SMTP
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "mail.frankkreutzer.com";
$mail->Port = 465; // 587 | 465
// $mail->IsHTML(true);

// Authentication
$mail->Username = "email@domain.com";
$mail->Password = "password";

// Compose
$mail->SetFrom($_POST['email'], $_POST['name']);
$mail->Subject = $_POST['subject'];
$mail->MsgHTML($message);

// Send to
$mail->AddAddress("recipient@domain.com"); // Where to send it

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
//创建消息
$message=
“名称:”.$\u POST['Name']”。
主题:'.$\u POST['Subject'].
电子邮件:'.$\u POST['Email'].
消息:'.$\u POST['Message'].' '; 需要“phpmailer/phpmailerautoad.php”; //实例化类 $mail=new PHPMailer(); //设置SMTP $mail->IsSMTP();//启用SMTP $mail->SMTPDebug=1;//调试:1=错误和消息,2=仅消息 $mail->SMTPAuth=true;//启用身份验证 $mail->SMTPSecure='ssl';//Gmail需要启用安全传输 $mail->Host=“mail.frankreutzer.com”; $mail->Port=465;//587 | 465 //$mail->IsHTML(true); //认证 $mail->Username=”email@domain.com"; $mail->Password=“Password”; //谱写 $mail->SetFrom($_POST['email'],$_POST['name']); $mail->Subject=$\u POST['Subject']; $mail->MsgHTML($message); //寄往 $mail->AddAddress(“recipient@domain.com"); // 寄到哪里 如果(!$mail->Send()){ 回显“邮件错误:”.$mail->ErrorInfo; }否则{ 回显“消息已发送”; }
刚刚修复了PHP代码:

<?php
require 'phpmailer/PHPMailerAutoload.php';

//Creating the message
$message =
'Name:  '.$_POST['name'].'<br />
Email:  '.$_POST['email'].'<br /><br />
Subject:    '.$_POST['subject'].'<br />
Message:    '.$_POST['message'].'
';

// Instantiate Class
$mail = new PHPMailer();

// Set up SMTP
$mail->IsSMTP(); // enable SMTP
// $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages 
only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // 587 | 465
// $mail->IsHTML(true);

// Authentication
$mail->Username = "example@email.com";
$mail->Password = "password";

// Compose
$mail->setFrom($_POST['email']);
$mail->Subject = $_POST['subject'];
$mail->MsgHTML($message);

// Send to
$mail->AddAddress("example@email.com"); // Where to send it

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent. I'll get back to you as soon as possible!";
}
?>

$mail->From=“sender id”//missing?你是说只添加那一行?