Verwenden PHPMailer Bibliothek nothing.Even. Es ist besser, als native Mail-Funktion zu verwenden, da Sie in PHPMailer Benutzerauthentifizierung verwenden können, um zu vermeiden, die E-Mail an Spam zu senden. Sie können diese Bibliothek verwenden, ohne einen Mailserver zu konfigurieren. Es ist am einfachsten zu debuggen. Sie können https://github.com/PHPMailer/PHPMailer
Sehen Sie ein Beispiel in diesem Link herunterladen:
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->Port = 587; // SMTP port
$mail->Username = "[email protected]"; // username
$mail->Password = "yourpassword"; // password
$mail->SetFrom('[email protected]', 'Test');
$mail->Subject = "I hope this works!";
$mail->MsgHTML('Blah');
$address = "[email protected]";
$mail->AddAddress($address, "Test");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
Ist das auf einem lokalen Host oder auf einem gehosteten Server? – Qirel
Localhost @Qirel –
Mail-Funktion funktionierte nicht in localhost –