Пример #1
0
// display XPM4 errors
// path to 'SMTP.php' file from XPM4 package
require_once '../SMTP.php';
$f = '*****@*****.**';
// from (Gmail mail address)
$t = '*****@*****.**';
// to mail address
$p = 'password';
// Gmail password
// standard mail message RFC2822
$m = 'From: ' . $f . "\r\n" . 'To: ' . $t . "\r\n" . 'Subject: test' . "\r\n" . 'Content-Type: text/plain' . "\r\n\r\n" . 'Text message.';
// connect to 'smtp.gmail.com' via SSL (TLS encryption) using port '465' and timeout '10' secounds
// make sure you have OpenSSL module (extension) enable on your php configuration
$c = fsockopen('tls://smtp.gmail.com', 465, $errno, $errstr, 10) or die($errstr);
// expect response code '220'
if (!SMTP::recv($c, 220)) {
    die(print_r($_RESULT));
}
// EHLO/HELO
if (!SMTP::ehlo($c, 'localhost')) {
    SMTP::helo($c, 'localhost') or die(print_r($_RESULT));
}
// AUTH LOGIN/PLAIN
if (!SMTP::auth($c, $f, $p, 'login')) {
    SMTP::auth($c, $f, $p, 'plain') or die(print_r($_RESULT));
}
// MAIL FROM
SMTP::from($c, $f) or die(print_r($_RESULT));
// RCPT TO
SMTP::to($c, $t) or die(print_r($_RESULT));
// DATA