私は電子メールアドレスを要求するフォームを持っています。顧客が電子メールフィールドの電子メールアドレスではない場合、例:[email protected]ではなく電子メールフィールドにGeorgeが必要ですが、依然としてフォームを送信します。 私はphpmailerそのものを想定しており、私はそれを修正する方法を知らない。アドレスが無効であっても電子メールを送信する、phpmailer
class.phpmailer.phpの設定は変更できますか?
<?php
//values to be inserted in database table
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$phone = $_POST['phone'] ;
$make = $_POST['make'] ;
$model = $_POST['model'] ;
$year = $_POST['year'] ;
$vin = $_POST['vin'] ;
$insurance_company = $_POST['insurance_company'] ;
$name = $_POST['name'] ;
$message = $_POST['message'] ;
$IP = $_SERVER['REMOTE_HOST'] ?: gethostbyaddr($_SERVER['REMOTE_ADDR']);
if (isset($_POST['submit'])){
//cleans the data
$_POST = preg_replace("/[^-,A-Za-z0-9,@,')','(','.' ]/", "",$_POST);
//connect to db
$db = new mysqli('localhost','user','pass','database');
//MySqli Insert Query
$insert_row = $db->query("INSERT INTO `data`(`name`, `email`, `phone`, `IP`) VALUES ('$name','$email','$phone','$IP')");
$token = $_SESSION['delete_customer_token'];
unset($_SESSION['delete_customer_token']);
session_write_close();
//check if post form was submitted
if(isset($_POST)){
//check if hidden value was used
if(isset($_POST['miles']) && trim($_POST['miles']) !=''){
die('THERE WAS AN ERROR');
}
//implode all the post data and check against bad words in a text file
$my_bad_file = "inc/words.txt"; //make a new file and insert any bad items one per line, Phrases work as well
if(!file_exists($my_bad_file)){
die("Can't find $my_bad_file");
}
$check_content = implode(",", $_POST);
$bad_content_array = array_map('rtrim', file($my_bad_file));
foreach ($bad_content_array as $bad_content) {
$bad_content = strtolower($bad_content);
if (strpos(strtolower($check_content), $bad_content) !== false) {
die('THERE WAS A BAD ERROR');
}}
}
require 'inc/PHPMailer/PHPMailerAutoload.php';
// PHPmailer settings
$mail = new PHPMailer(); // create a new object
$mail->Issmtp(); // enable SMTP
$mail->SMTPDebug = true;
$mail->do_debug = 1;
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "password"; // SMTP password
$mail->FromName = $email;
$mail->SetFrom($email);
$mail->AddAddress('[email protected]');
$mail->Priority = 1;
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = "company name | Repair Quote"; \t
$mail->AltBody = "This is the text-only body";
// defines how message looks in email
$mail->Body="
<html>
<head>
</head>
<body>
<center>
<span style='color:red;'>This customer needs a repair quote. Lets not keep him waiting!</span>
<div style='width:750px;text-align:center;'>
<div style='float:;'>
<span style='font-size:px;'><b>Personal Info</b><br></span>
<br>
<span style='font-size:px;'>---------------<br></span>
<br>
<span style='font-size:px;'><span style='font-size:px;color:red;'>Full Name: </span>$name<br></span>
<br>
<span style='font-size:px;'><span style='font-size:px;color:red;'>Phone Number:</span> $phone<br></span>
<br>
<span style='font-size:px;'><span style='font-size:px;color:red;'>Email:</span> $email<br></span>
</div>
<br>
<div style='float:;'>
<span style='font-size:px;'><b>Vehicle Info</b><br></span>
<br>
<span style='font-size:px;'>---------------<br></span>
<br>
<span style='font-size:px;'><span style='font-size:px;color:red;'>Vehicle make:</span> $make<br></span>
<br>
<span style='font-size:px;'><span style='font-size:px;color:red;'>Vehicle Model:</span> $model<br></span>
<br>
<span style='font-size:px;'><span style='font-size:px;color:red;'>Year:</span> $year<br></span>
<br>
<span style='font-size:px;'><span style='font-size:px;color:red;'>Vin:</span> $vin<br></span>
<br>
<span style='font-size:px;'><span style='font-size:px;color:red;'>Insurance Company:</span> $insurance_company<br></span>
<br>
<span style='font-size:px;'><span style='font-size:px;color:red;'>Message:</span>$message<br></span>
</div>
</div>
</center>
</body>
</html>
";
// looks good in your inbox
$mail->From = "$email";
$mail->FromName = "$name";
$mail->AddReplyTo("$email","$name");
$mail->SetFrom('$email', '$name');
// gives success or error
if(!$mail->Send()) {
echo 'Message could not be sent.';
exit;
} else{
echo '
<meta http-equiv="refresh" content="0;url=http://website.com/index.php">
';}
}
?>
クラスの境界チェックのショートカットは、それを「修正」していません。 ;-) ユーザーに電子メールを送信させます。 –
一部の顧客は電子メールを持っておらず、そのためにビジネスを失おうとしていません。私が必要とするのは、彼らが電話番号を持っていることを確認することだけです。私が検証したいのであれば、if文とelse文を使います。 – jlitt1