PHP: Mail über SMTP schicken
Aus Salber.net
So kann mit PHP über SMTP eine Mail verschickt werden:
require_once "Mail.php"; function sendMail($to, $subject, $body) { $from = "<foo@example.org>"; $host = "ssl://smtp.example.org"; $port = "465"; $username = "foo@example.org"; $password = "foobar"; $headers = array ( 'From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ( 'host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); return !(PEAR::isError($mail)); } $erfolg = sendMail("<foo@example.com>", "Foobar", "Lorem Ipsum");