Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
require 'Net/SMTP.php';
4
 
5
$host = 'mail.example.com';
6
$from = 'user@example.com';
7
$rcpt = array('recipient1@example.com', 'recipient2@example.com');
8
$subj = "Subject: Test Message\n";
9
$body = "Body Line 1\nBody Line 2";
10
 
11
/* Create a new Net_SMTP object. */
12
if (! ($smtp = new Net_SMTP($host))) {
13
    die("Unable to instantiate Net_SMTP object\n");
14
}
15
 
16
/* Connect to the SMTP server. */
17
if (PEAR::isError($e = $smtp->connect())) {
18
    die($e->getMessage() . "\n");
19
}
20
 
21
/* Send the 'MAIL FROM:' SMTP command. */
22
if (PEAR::isError($smtp->mailFrom($from))) {
23
    die("Unable to set sender to <$from>\n");
24
}
25
 
26
/* Address the message to each of the recipients. */
27
foreach ($rcpt as $to) {
28
    if (PEAR::isError($res = $smtp->rcptTo($to))) {
29
        die("Unable to add recipient <$to>: " . $res->getMessage() . "\n");
30
    }
31
}
32
 
33
/* Set the body of the message. */
34
if (PEAR::isError($smtp->data($subj . "\r\n" . $body))) {
35
    die("Unable to send data\n");
36
}
37
 
38
/* Disconnect from the SMTP server. */
39
$smtp->disconnect();