が最高の状態であなたが信頼できないメールが実際に送信されるかどうかを知りませんか、あなたがきた好きではありませんさヘッダーをメールに送信したことが判明したため、配信される可能性が高くなります。
$headers = "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if(mail($to, $sub, $msg, $headers)){
echo "<p>Email Sent</p>";
}
より良いアプローチはphpmailerの使用することです - ここhttps://github.com/PHPMailer/PHPMailer
は、電子メールを送信する彼らのサンプルです
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('[email protected]', 'Mailer');
$mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo('[email protected]', 'Information');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
phpmailerのは非常に柔軟であり、非常に少しのオプションで使用することができ、それはまた、することができSMTPを使用するように設定されている場合は、認証されたアカウントで電子メールを送信したり、SendGridなどのサードパーティの電子メールサービスを使用して配信したり、電子メールを監視したりすることもできます。 https://sendgrid.com/
"emailid"とは何ですか?この質問は意味をなさない。 –
ようこそスタックオーバーフロー! [コードを画像として投稿しないでください。](// meta.stackoverflow.com/q/285551) – FrankerZ
[PHPメールフォームでは電子メールの送信が完了しません](http:// stackoverflow。 com/questions/24644436/php-mail-form-doesnt-complete-sending-e-mail) – FrankerZ