のPHPMailerのヘルプを使ってメールを送信できません。送信ボタンをクリックするたびに常に0値(else部分)を出します。 Yii 2.0フレームワークのPHPMailerの助けを借りてサーバにメールを送ることができません。Yii 2.0フレームワークのPHPMailerの助けを借りてサーバにメールを送ることができません。私を助けて、事前に感謝してください!あなたは、フレームワークを使用するつもりなら、使用フレームワーク -私は送信ボタンをクリックするたびに、yay 2.0
<?php
//Check e-mail validation
function check_email($email){
if([email protected]("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
return false;
} else {
return true;
}
}
function validate_mobile($mobile)
{
return preg_match('/^[0-9]{10}+$/', $mobile);
}
//Get post data
if(isset($_POST['name']) and isset($_POST['email']) and isset($_POST['mobile'])){
$name = $_POST['name'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$comment = $_POST['comment'];
if($name == '') {
echo json_encode(array('info' => 'error', 'msg' => "Please enter your name."));
exit();
} else if($email == '' or check_email($email) == false){
echo json_encode(array('info' => 'error', 'msg' => "Please enter valid e-mail."));
exit();
} else if($mobile == '' or validate_mobile($mobile) == false){
echo json_encode(array('info' => 'error', 'msg' => "Please enter 10 digit mobile number."));
exit();
} else if($comment == ''){
echo json_encode(array('info' => 'error', 'msg' => "Please enter your message."));
exit();
} else {
$message = '
<html>
<head>
<title>Mail from '. $name .'</title>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" class="tableContent bgBody" align="center" style="font-family:Helvetica, sans-serif; width:100%;">
<tr>
<td style="padding-bottom: 28px;">
<table style="font-size:14px;width:100%;">
<tr>
<td style="width:18%;">
<b>Name :</b>
</td>
<td>
<span style="">
'.$name.'
</span>
</td>
</tr>
<tr>
<td style="width:18%;">
<b>Email :</b>
</td>
<td>
<span style="">
'.$email.'
</span>
</td>
</tr>
<tr>
<td>
<b>Contact Number :</b>
</td>
<td>
<span style="">
'.$mobile.'
</span>
</td>
</tr>
<tr>
<td>
<b>Message :</b>
</td>
<td>
<span style="">
'.$comment.'
</span>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
';
require 'PHPMailer/PHPMailerAutoload.php';
//Send Mail
$mail->addReplyTo = "[email protected]";
$mail->subject = 'Xion-Solutions';
$mail->setFrom = $email;
$mail->Body = $message;
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPSecure = 'ssl';
$mail->SMTPDebug = 1;
$mail->Debugoutput = 'html';
$mail->isSMTP();
$mail->Host = 'mail.xionproaudio.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = '[email protected]$';
$mail->Port = 465;
$mail->IsHTML(true);
if($mail->send()){
echo 1;
}else{
echo 0;
}
}
} else {
echo json_encode(array('info' => 'error', 'msg' => __MESSAGE_EMPTY_FILDS__));
}
?>
どのようなエラーが発生しますか? – ArtOsi
Yiiのメーラーを使っていないのはなぜですか? http://www.yiiframework.com/doc-2.0/guide-tutorial-mailing.html – kyle
エラーが発生しました。 $ mail-> ErrorInfoには – Chux