I have a basic HTML template that comes with phpmailer
that uses STMP
This code has been configured as straight from unzipping.
<?php
session_start();
include("php/simple-php-captcha/simple-php-captcha.php");
include("php/php-mailer/PHPMailerAutoload.php");
$to = 'you@domain.com';
if(isset($_POST['emailSent'])) {
$subject = $_POST['subject'];
if (strtolower($_POST["captcha"]) == strtolower($_SESSION['captcha']['code'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$fields = array(
0 => array(
'text' => 'Name',
'val' => $_POST['name']
),
1 => array(
'text' => 'Email address',
'val' => $_POST['email']
),
2 => array(
'text' => 'Message',
'val' => $_POST['message']
),
3 => array(
'text' => 'Checkboxes',
'val' => implode($_POST['checkboxes'], ", ")
),
4 => array(
'text' => 'Radios',
'val' => $_POST['radios']
)
);
$message = "";
foreach($fields as $field) {
$message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
}
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->From = $email;
$mail->FromName = $_POST['name'];
$mail->AddAddress($to);
$mail->AddReplyTo($email, $name);
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Subject = $subject;
$mail->Body = $message;
if (isset($_FILES['attachment']) && $_FILES['attachment']['error'] == UPLOAD_ERR_OK) {
$mail->AddAttachment($_FILES['attachment']['tmp_name'], $_FILES['attachment']['name']);
}
if($mail->Send()) {
$arrResult = array('response'=> 'success');
} else {
$arrResult = array('response'=> 'error', 'error'=> $mail->ErrorInfo);
}
} else {
$arrResult['response'] = 'captchaError';
}
}
?>
After setting each variable up, including all steps 4. I continue to receive it SMTP connect() failed.
even when debugging 3. Outlook is used in our sales email.
So, one of the problems, I think, is that this site is hosted on Azure.
Another thing I wanted to do was set up the 365 office using their contact form API. There is some javascript code there, but authContext = new O365Auth.Context();
not recognized.
sales@email.com
, . , , , .