Immer wenn ich die Kopfzeilen zu mail()
hinzugefügt habe, erhält der Empfänger keine E-Mail.PHP Mail Header funktioniert nicht?
Dies funktioniert ok:
// The message
$message = "Line 1\r\nLine 2\r\nLine 3";
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70, "\r\n");
// Send
mail('[email protected]', 'My Subject 2', $message);
Das ist nicht in Ordnung ist:
// The message
$message = "Line 1\r\nLine 2\r\nLine 3";
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70, "\r\n");
// Send with headers
mail('[email protected]', 'My Subject', $message, 'From: Test <[email protected]>');
Irgendwelche Ideen, warum?
EDIT:
Es scheint, dass es durch die @yahoo.co.uk
E-Mail-Adressen verursacht wird. Es ist in Ordnung mit @gmail.com
!
Warum! ??? Ist es etwas mit meinem Produktionsserver?
EDIT 2:
Die gleiche Sache geschieht, obwohl ich PHPMailer verwenden:
// Include Composer autoloader.
require_once __DIR__ . '/vendor/autoload.php';
$mail = new PHPMailer;
$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->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';
}
Aber es funktioniert ok mit @gmail.com
:
$mail->setFrom('[email protected]', 'Mailer');
Ich weiß, dass dies keine Antwort auf Ihre genaue Frage ist, aber haben Sie darüber nachgedacht, eine vorhandene Bibliothek wie PHPMailer zu verwenden, die sich darum kümmert? – systematical
Wie benutze ich es? – laukok
https://github.com/PHPMailer/PHPMailer – systematical