0
私のPHPサーバには小さな問題があります。 $ POSTメソッドで回復したデータを電子メールで送信しようとしています。私はこれを行う場合は は、コードが動作すると、メールが送信されます。PHPでデータを回復するPOST
<?php
header('Access-Control-Allow-Origin: *');
header('Content-type: text/json');
$nom = "";
if(isset($_POST['votre_nom']))
{
$nom = htmlspecialchars($_POST['votre_nom']);
}
require_once('class.phpmailer.php');
require_once('class.smtp.php');
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "[email protected]";
$mail->Password = "!Paswword";
$mail->SetFrom("[email protected]", "TEST", 0);
$mail->Subject = "Test";
$mail->Body = "hello" . nom . ;
$mail->AddAddress("[email protected]", "Person One");
$mail->AddCC('[email protected]', 'Person Two');
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
?>
を私はデータを追加するとき、それは次のコードのように、私は500エラーを与える:?
<?php
header('Access-Control-Allow-Origin: *');
header('Content-type: text/json');
require_once('class.phpmailer.php');
require_once('class.smtp.php');
$nom = "";
$email = "";
if(isset($_POST['votre_nom']) && isset($_POST['votre_email']))
{
$nom = htmlspecialchars($_POST['votre_nom']);
$email = htmlspecialchars($_POST['votre_email']);
}
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "[email protected]";
$mail->Password = "!Password";
$mail->SetFrom("[email protected]", "TEST", 0);
$mail->Subject = "TEST";
$mail->Body = "Prénom/Nom : " . $nom .
"</br>Email : " . $email .;
$mail->AddAddress("[email protected]", "Person One");
$mail->AddCC('[email protected]', 'Person Two');
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
>
エラーから来るかもしれないところ、私はチェックしたときに私のJSONのすべてがありますので、誰もが私に解決策を見つけるためにトラックを与えることができれば、私は..
を理解していない:)をしてください は
は、あなたのウェブサーバのログを確認しましたか? Apacheのエラーログなど? – madshvero