我正在尝试通过gmail插入php代码SMTP,因此它可以通过smtp.gmail.com发送,它似乎不起作用。我有人可以帮我一把,所以我可以让它工作,这将是一个很大的帮助。
P.S。有了这个scrpit,它可以在已经有smtp设置的服务器上运行。我正在尝试插入它,以便我可以在另一台带有邮件服务器的服务器上使用它。
`($host = "ssl://smtp.gmail.com";
$port = "465";
$username = "<wilkinsonsport2014@gmail.com>";
$password = "********";)`
`
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "<wilkinsonsport2014@gmail.com>";
$password = "********";
$mail_to = 'wilkinsonsport2014@gmail.com';
$name = $_POST['sender-name'];
$mail_from = $_POST['sender-email'];
$phone = $_POST['sender-phone'];
$message = $_POST['sender-message'];
$subject = 'localhost/wilkinson-sport Messaggio da un visitatore ' . $name;
$body_message .= 'Da: ' . $name . "\r\n";
$body_message .= 'E-mail: ' . $mail_from . "\r\n";
$body_message .= 'Telfono: ' . $phone . "\r\n";
$body_message .= 'Commenti: ' . $message;
$headers .= 'Da: ' . $mail_from . "\r\n";
$headers .= 'Rispondi a: ' . $mail_from . "\r\n";
$mail_sent = mail($mail_to, $subject, $body_message, $headers);
if ($mail_sent == true){
if (isset($_POST) && $_POST['accetto'] == "si")
{
echo ("<script>alert('Hai accettato il consenso privacy.')</script>");
}
else if (isset($_POST) && $_POST['accetto'] == "no")
{
echo ("<script>alert('Non hai accettato il consenso privacy. Riprova!')</script>");
}
else if (isset($_POST) && $_POST['entra'] == false)
{
echo ("<script>alert('Devi accettare il consenso privacy per accedere!')</script>");
}
}
?>`