我有与phpmailer
来到它使用STMPHTML形式的接触在Azure上托管网络应用
的代码是设置这样直接从解压一个基本的HTML模板。
<?php
session_start();
include("php/simple-php-captcha/simple-php-captcha.php");
include("php/php-mailer/PHPMailerAutoload.php");
// Step 1 - Enter your email address below.
$to = '[email protected]';
if(isset($_POST['emailSent'])) {
$subject = $_POST['subject'];
// Step 2 - If you don't want a "captcha" verification, remove that IF.
if (strtolower($_POST["captcha"]) == strtolower($_SESSION['captcha']['code'])) {
$name = $_POST['name'];
$email = $_POST['email'];
// Step 3 - Configure the fields list that you want to receive on the 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(); // Set mailer to use SMTP
$mail->SMTPDebug = 0; // Debug Mode
// Step 4 - If you don't receive the email, try to configure the parameters below:
//$mail->Host = 'mail.yourserver.com'; // Specify main and backup server
//$mail->SMTPAuth = true; // Enable SMTP authentication
//$mail->Username = 'username'; // SMTP username
//$mail->Password = 'secret'; // SMTP password
//$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$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;
// Step 5 - If you don't want to attach any files, remove that code below
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';
}
}
?>
设置每个变量时,包括所有的步骤4后,我继续获得SMTP connect() failed.
甚至与调试3.我们的销售邮件使用Outlook。
所以我认为的一个问题是,这个网站托管在Azure上。
我想要做的另一件事是设置office 365使用他们的API的联系表格。有一些javascript代码,但authContext = new O365Auth.Context();
未被识别。
我们只需要一种方式来填写一个基本的联系表格,并通过电子邮件发送到我们的[email protected]
我已经用完了这个想法。不管怎么样,但我是新来的天青,我卡住了。
我创建一个SendGrid应用程序现在,谢谢!你知道是否有一个与此类似的Office 365扩展? – teachtyler
Microsoft不建议将Office 365用于应用程序,但它的工作限制为30封电子邮件/分钟或10k /天。首先需要在Office 365中设置几件事情。看到这里https://technet.microsoft.com/en-us/library/dn554323(v=exchg.150).aspx。还发现这个关于连接到Office 365的错误线索,可能与您的情况类似。 –