По какой-то причине электронные письма не отправляются вообще. Я не получаю никаких консольных ошибок, поля ввода даже сброшены, как и предполагалось. Он обрабатывается на сервере Windows, поэтому требуется для gmail smtp. Есть предположения?smtp php сценарий электронной почты не отправляет электронную почту
<?php
require 'PHPMailerAutoload.php';
require_once('class.phpmailer.php');
include("class.smtp.php");
$emailaddress = '[email protected]';
$message=
'Name: '.$_POST['name'].'<br />
Email: '.$_POST['email'].'<br />
Phone: '.$_POST['phone'].'<br />
Comments: '.$_POST['comments'].'<br />
'.nl2br($_POST['message']).'
';
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
//$mail->SMTPDebug = 2; // 1 = errors and messages,2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "smtp.gmail.com"; // sets the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // SMTP account username (the email account your created)
$mail->Password = "[email protected]#$"; // SMTP account password (the password for the above email account)
$mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted
$mail->CharSet = 'UTF-8'; // so it interprets foreign characters
$mail->SetFrom($_POST['email']);
$mail->AddReplyTo($_POST['email']);
$mail->Subject = "Contact form from ".$_POST['name']." ";
$mail->MsgHTML($message);
$mail->AddAddress($emailaddress);
if(isset($_POST['submit'])) {
if(!$mail->send()) {
echo '<p class="contact-message">Message could not be sent.</p>';
echo '<p class="contact-message">Mailer Error: ' . $mail->ErrorInfo . '</p>';
} else {
echo '<p class="contact-message">Your message has been sent. We will be in touch.';
}
}
?>
<form role="form" method="post" id="contact-form" name="myemailform" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>#contact-form">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12 "><input type="text" class="form-control" name="name" placeholder="Name*"></div>
<div class="col-sm-12 col-md-12 col-lg-12"><input type="text" class="form-control" name="email" placeholder="E-mail*"></div>
<div class="col-sm-12 col-md-12 col-lg-12"><input type="text" class="form-control" name="phone" placeholder="Telephone Number"></div>
<div class="col-sm-12 col-md-12 col-lg-12"><textarea name="comments" class="form-control commentBox" placeholder="Comments"></textarea></div>
<div class="col-sm-12 col-md-12 col-lg-12"><input type="submit" value="Send Form" class="form-control submitButton"></div>
</div>
</form>
ОШИБОК ИЗ MAMP PHP_ERROR.LOG
[12-Jan-2015 17:27:06 America/New_York] PHP Notice: Undefined index: name in /Users/andrewlevy/Documents/deepseadiving/index.php on line 22
[12-Jan-2015 17:27:06 America/New_York] PHP Notice: Undefined index: email in /Users/andrewlevy/Documents/deepseadiving/index.php on line 23
[12-Jan-2015 17:27:06 America/New_York] PHP Notice: Undefined index: phone in /Users/andrewlevy/Documents/deepseadiving/index.php on line 24
[12-Jan-2015 17:27:06 America/New_York] PHP Notice: Undefined index: comments in /Users/andrewlevy/Documents/deepseadiving/index.php on line 25
[12-Jan-2015 17:27:06 America/New_York] PHP Notice: Undefined index: message in /Users/andrewlevy/Documents/deepseadiving/index.php on line 26
[12-Jan-2015 17:27:06 America/New_York] PHP Notice: Undefined index: email in /Users/andrewlevy/Documents/deepseadiving/index.php on line 39
[12-Jan-2015 17:27:06 America/New_York] PHP Notice: Undefined index: email in /Users/andrewlevy/Documents/deepseadiving/index.php on line 40
[12-Jan-2015 17:27:06 America/New_York] PHP Notice: Undefined index: name in /Users/andrewlevy/Documents/deepseadiving/index.php on line 41
[12-Jan-2015 17:28:15 America/New_York] PHP Notice: Undefined index: name in /Users/andrewlevy/Documents/deepseadiving/index.php on line 22
[12-Jan-2015 17:28:15 America/New_York] PHP Notice: Undefined index: email in /Users/andrewlevy/Documents/deepseadiving/index.php on line 23
[12-Jan-2015 17:28:15 America/New_York] PHP Notice: Undefined index: phone in /Users/andrewlevy/Documents/deepseadiving/index.php on line 24
[12-Jan-2015 17:28:15 America/New_York] PHP Notice: Undefined index: comments in /Users/andrewlevy/Documents/deepseadiving/index.php on line 25
[12-Jan-2015 17:28:15 America/New_York] PHP Notice: Undefined index: message in /Users/andrewlevy/Documents/deepseadiving/index.php on line 26
[12-Jan-2015 17:28:15 America/New_York] PHP Notice: Undefined index: email in /Users/andrewlevy/Documents/deepseadiving/index.php on line 39
[12-Jan-2015 17:28:15 America/New_York] PHP Notice: Undefined index: email in /Users/andrewlevy/Documents/deepseadiving/index.php on line 40
[12-Jan-2015 17:28:15 America/New_York] PHP Notice: Undefined index: name in /Users/andrewlevy/Documents/deepseadiving/index.php on line 41
[12-Jan-2015 17:28:17 America/New_York] PHP Notice: Undefined index: name in /Users/andrewlevy/Documents/deepseadiving/index.php on line 22
[12-Jan-2015 17:28:17 America/New_York] PHP Notice: Undefined index: email in /Users/andrewlevy/Documents/deepseadiving/index.php on line 23
[12-Jan-2015 17:28:17 America/New_York] PHP Notice: Undefined index: phone in /Users/andrewlevy/Documents/deepseadiving/index.php on line 24
[12-Jan-2015 17:28:17 America/New_York] PHP Notice: Undefined index: comments in /Users/andrewlevy/Documents/deepseadiving/index.php on line 25
[12-Jan-2015 17:28:17 America/New_York] PHP Notice: Undefined index: message in /Users/andrewlevy/Documents/deepseadiving/index.php on line 26
[12-Jan-2015 17:28:17 America/New_York] PHP Notice: Undefined index: email in /Users/andrewlevy/Documents/deepseadiving/index.php on line 39
[12-Jan-2015 17:28:17 America/New_York] PHP Notice: Undefined index: email in /Users/andrewlevy/Documents/deepseadiving/index.php on line 40
[12-Jan-2015 17:28:17 America/New_York] PHP Notice: Undefined index: name in /Users/andrewlevy/Documents/deepseadiving/index.php on line 41
[12-Jan-2015 17:28:56 America/New_York] PHP Notice: Undefined index: message in /Users/andrewlevy/Documents/deepseadiving/index.php on line 26
[12-Jan-2015 17:29:04 America/New_York] PHP Notice: Undefined index: message in /Users/andrewlevy/Documents/deepseadiving/index.php on line 26
Вы проверили, установлен ли SMTP, как я читаю здесь: 'SMTP-сервер не установлен по умолчанию. SMTP можно добавить через область «Сводка характеристик» средства «Диспетчер серверов» в Windows Server » – Neat
@KoenHoeijmakers hes uding сервер gmail –
вы получаете к отправленному сообщению или не отправленному сообщению? –