Für das Konto My ISP
Muss ein Benutzername und ein Kennwort für ausgehende E-Mails SMTP
gesendet werden.
Wie kann ich PHP
veranlassen, dies beim Ausführen von php.mail()?
zu verwenden? Die Datei php.ini
Enthält nur Einträge für den Server (SMTP= )
Und From: (sendmail_from= )
. .
Der Befehl PHP mail()
unterstützt keine Authentifizierung. Deine Optionen:
Ich wende folgende Informationen auf die Datei php.ini an. es funktioniert gut.
SMTP = smtp.example.com
smtp_port = 25
username = [email protected]
password = yourmailpassord
sendmail_from = [email protected]
Diese Details sind dieselben wie in den Outlook-Einstellungen.
Verwenden Sie Fake sendmail for Windows , um E-Mails zu senden.
sendmail
in C:\wamp\
.sendmail
: sendmail.exe
, libeay32.dll
, ssleay32.dll
und sendmail.ini
.C:\wamp\sendmail\sendmail.ini
:smtp_server=smtp.gmail.com smtp_port=465 [email protected] auth_password=your_password
Das oben Genannte funktioniert mit einem Google Mail-Konto. Und dann konfiguriere php.ini:
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
Starten Sie jetzt Apache neu, und das ist im Grunde alles, was Sie tun müssen.
PHP hat Authentifizierung auf dem Mail-Befehl!
Folgendes funktioniert für mich auf WAMPSERVER (Windows, PHP 5.2.17)
php.ini
[mail function]
; For Win32 only.
SMTP = mail.yourserver.com
smtp_port = 25
auth_username = smtp-username
auth_password = smtp-password
sendmail_from = [email protected]
Ich bevorzuge das PHPMailer Tool, da es kein PEAR benötigt. In beiden Fällen haben Sie ein Missverständnis: Sie möchten keine PHP-serverweite Einstellung für den SMTP-Benutzer und das Kennwort. Dies sollte eine Einstellung pro App (oder pro Seite) sein. Wenn Sie dasselbe Konto auf verschiedenen PHP Seiten verwenden möchten, fügen Sie es einer Art settings.php-Datei hinzu.
Nachdem ich den ganzen Tag daran gearbeitet hatte, fand ich endlich eine Lösung. So sende ich aus Windows XP mit WAMP.
<?php $message = "test message body"; $result = mail('[email protected]', 'message subject', $message); echo "result: $result"; ?>
Referenz:
/etc/postfix/main.cf
, Um Folgendes zu lesen:#Relay config
relayhost = smtp.server.net
smtp_use_tls=yes
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_sasl_security_options = noanonymous
/etc/postfix/sasl_passwd
, Geben Sie ein:smtp.server.net username:password
Tippe # /usr/sbin/postmap sasl_passwd
Führen Sie dann Folgendes aus: service postfix reload
Jetzt führt PHP mit dem Befehl sendmail -t -i
Mail wie gewohnt aus und Postfix fängt sie ab und leitet sie an Ihren von Ihnen angegebenen SMTP-Server weiter.
Verwenden Sie Mail :: factory im Paket Mail PEAR. Beispiel.
Diese Antworten sind veraltet und nicht mehr aktuell. Beste Übung..
composer require phpmailer/phpmailer
Die nächsten in Ihrer sendmail.php-Datei erfordern nur Folgendes
# use namespace
use PHPMailer\PHPMailer\PHPMailer;
# require php mailer
require_once "../vendor/autoload.php";
//PHPMailer Object
$mail = new PHPMailer;
//From email address and name
$mail->From = "[email protected]";
$mail->FromName = "Full Name";
//To address and name
$mail->addAddress("[email protected]", "Recepient Name");
$mail->addAddress("[email protected]"); //Recipient name is optional
//Address to which recipient will reply
$mail->addReplyTo("[email protected]", "Reply");
//CC and BCC
$mail->addCC("[email protected]");
$mail->addBCC("[email protected]");
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
Dies kann nach Belieben konfiguriert werden.
"SMTP = localhost",
"smtp_port = 25",
"; sendmail_path =".
Guthaben: Wie konfiguriere ich WAMP (localhost), um E-Mails mit Google Mail zu senden?
Unter Berücksichtigung einer Antwort in diese Frage , In PHP 4 ist das PEAR Mail-Paket normalerweise bereits installiert, und dieses wirklich einfache Tutorial zeigt Sie die wenigen Codezeilen, die Sie zu Ihrer PHP-Datei hinzufügen müssen http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm