2016-07-07 17 views
0
 <html> 
     <form method="post" action="email.php"> 
    Email: <input name="email name" id="email" type="text" /><br/> 
     Message:<br/><text area name="message" id="message" rows="15" cols="40</text area><br> 
     <input type="submit" value="Submit" /> 
     </form> 
    <html/> 

ich diesen Code habe mit auf Kontaktformular senden und ich mag [email protected] auf einem Kontaktformular E-Mail senden, aber es sagt mindestens einen Empfänger eingeben und wenn ich Eingabe E-Mail an $ mail -> Adresse hinzufügen ($ email) wenn ich zu $ ​​mail-> addadress ([email protected]) wechsle, auch wenn die E-Mail auf einem Formular anders ist als der Standard, den es an [email protected] sendet, bitte hilf mir.wie phpmailer

<?php 
$email = $_REQUEST['email'] ; 
$message = $_REQUEST['message'] ; 

require("PHPMailerAutoload.php"); 
require "class.phpmailer.php"; 

$mail = new PHPMailer(); 
$mail->IsSMTP(); 
$mail->SMTPAuth = true;  // turn on SMTP authentication 
$mail->SMTPSecure = "tls"; 
$mail->Port  = 587; 

$mail->Host = "smtp.gmail.com"; 
$mail->Username = "[email protected]"; // SMTP username 
$mail->Password = "*************"; // SMTP password 
$mail->AddAddress=$email; 
$mail->IsHTML(true); 
$mail->Subject = "You have received feedback from your website!"; 
$mail->Body = $message; 
$mail->AltBody = $message; 

if(!$mail->Send()) 
{ 
    echo "Message could not be sent. <p>"; 
    echo "Mailer Error: " . $mail->ErrorInfo; 
    exit; 
} 

echo "Message has been sent"; 
?> 
+0

'addAddress' ist eine Funktion innerhalb der PHPMailer Klasse, so dass Sie die gewünschte E-Mail als Argument übergeben müssen. – MonkeyZeus

Antwort

2

AddAddress ist eine Methode, keine Eigenschaft.

$mail->AddAddress=$email; 

Sollte sein:

$mail->AddAddress($email); 
+0

Vielen Dank für Ihren Kommentar, aber immer noch atleast eine receipent hinzufügen – Gezachew

+0

zu https://github.com/PHPMailer/PHPMailer/issues/441 finden. Überprüfen Sie die Ausgabe von 'var_dump (PHPMailer :: validateAddress ($ email));', um den Fehler auszuschließen. Welche Version von PHP? – Devon

+0

php5.5.12 version – Gezachew