なぜ動作しないのかわかりません。私の知る限り、いくつかの点で私のポストの要求を理解し、それはそうここに...受け入れられていない私のコードはもちろんのことPhpMailer無効なアドレス:(setFrom)
<meta charset="utf-8" type="text/html">
<?php
echo !extension_loaded('openssl')?"Not Available":"Available";
echo'<br>';
include 'PHPMailer/PHPMailerAutoload.php';
$name = $_POST['nombre'];
$mailfrom = $_POST['email'];
$context = $_POST['context'];
echo $name,$mailfrom,$context;
echo "<br>";
echo "<br>";
$subject = 'Information';
/*i'm not sure if i can use any gmail or it needs to be
registred on my server admin panel*/
$to ="[email protected]";
define ('GUSER','[email protected]');
define ('GPWD','pass');
// make a separate file and include this file in that. call this function in that file.
function smtpmailer($mailfrom, $name, $subject, $context) {
global $error;
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 2; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail
$mail->SMTPAutoTLS = false;
$mail->Host = 'ssl://smtp.gmail.com';
$mail->Port = 587;
$mail->CharSet = "UTF-8";
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->SetFrom ($mailfrom); //here it's my error
$mail->Subject = $subject;
$mail->Body = $context;
$mail->AddAddress('[email protected]');
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
}
smtpmailer();
?>
その他の重要なものです。これは私のホスティングプロバイダが私に与える設定です。そして、私が適切に使用しているかどうかはわかりません。私はすべてのポートとホストで試しましたが、同じエラーが発生します。
私は本当にすべての助けに感謝:)
setFormには2つの引数が必要です。最初にメールアドレスを、2番目に文字列には何かを指定します。ここでは、phpmailerの公式ホームページのサンプル: '$ mail-> setFrom('[email protected] '、' Your Name ');' $ mailFormの内容が本当に文字列か有効であるかをチェックする必要がありますメールアドレス – mtizziani
はまだ同じエラーを受け取りました –
いいえ、 'setFrom'の2番目のパラメータはオプションです。無効なアドレスを指定すると' false'が返されますので、事前に確認する必要はありません。値。 – Synchro