2016-08-18 5 views
1

私はPHPMailerを初めて使用しています。私のlocalhostではうまくいきますが、ライブではうまくいきません。メッセージ「無効なアドレス」を含むphpmailerException

私はこのエラーを取得する:

if (!self::ValidateAddress($address)) { 
     $this->SetError($this->Lang('invalid_address').': '. $address); 
     if ($this->exceptions) { 
     throw new phpmailerException($this->Lang('invalid_address').': '.$address); 
     } 
     if ($this->SMTPDebug) { 
     echo $this->Lang('invalid_address').': '.$address; 
     } 
     return false; 
    } 

/directoryhere/test/public_html/scripts/phpmailer/class.phpmailer.php(438)

Fatal error: Uncaught exception 'phpmailerException' with message 'Invalid address: ' in /directoryhere/test/public_html/scripts/phpmailer/class.phpmailer.php:498 Stack trace: #0 /directoryhere/test/public_html/scripts/phpmailer/class.phpmailer.php(438): PHPMailer->AddAnAddress('to', '', '') #1 /directoryhere/test/public_html/scripts/include.php(189): PHPMailer->AddAddress('', '') #2 /directoryhere/test/public_html/forgot.php(49): send_mail() #3 /directoryhere/test/public_html/index.php(141): include('/home1/test...') #4 {main} thrown in /directoryhere/test/public_html/scripts/phpmailer/class.phpmailer.php on line 498

これは、コードの行

/directoryhere/test/public_html/scripts/phpmailer/class.phpmailer.php:498ある

public function AddAddress($address, $name = '') { 
    return $this->AddAnAddress('to', $address, $name); 
    } 

でした誰もこれの原因となる可能性のあるものを教えてください。

+0

私は、新しいメールホストが必要ですか? –

+0

このエラーメッセージは、電子メールアドレスをまったく渡していないことを示しています。そのため、PHPMailerではなく、呼び出しコードを確認してください。 – Synchro

+0

まあ、**あなたが投げるアドレスは何ですか**ですか? – m02ph3u5

答えて

0

@Synchro @ m02ph3u5それを指摘していただきありがとうございます!今はうまくいきます。問題は送信コードにあります。電子メールの値は空ですが、ページが読み込まれると送信ボタンが起動します。だから私がやったのは、最初にフォームをロードし、電子メールの入力が空であればキャッチし、空でなければ送信ボタンが有効になり、発射する準備が整ったということです。

私は提出する前に、ここで行のコードを追加し、メール機能を呼び出す:

if(isset($_POST["retrieve"])) { //name of button 

//submission and calling mail function here 

} 
関連する問題