пакет PEAR::Net_SMTP

RATA

Новичок
пакет PEAR::Net_SMTP

Доброго времени суток!

Вообщем возникла такая проблема:
вот код, который я использую для соединения с почтовым сервером и отправляю на ящик письмо, посредство пакета Net_SMTP

<?
require_once('Net/SMTP.php');


$host = 'mail.farline.net';
$from = '[email protected]';
$rcpt = array('[email protected]');
$subj = "Subject: Test Message\n";
$body = "Body Line 1\nBody Line 2";

/* Create a new Net_SMTP object. */
if (! ($smtp = new Net_SMTP($host))) {
die("Unable to instantiate Net_SMTP object\n");
}

$smtp->setDebug(true);

/* Connect to the SMTP server. */
if (PEAR::isError($e = $smtp->connect())) {
die($e->getMessage() . "\n");
}

/* Send the 'MAIL FROM:' SMTP command. */
if (PEAR::isError($smtp->mailFrom($from))) {
die("Unable to set sender to <$from>\n");
}

/* Address the message to each of the recipients. */
foreach ($rcpt as $to) {
if (PEAR::isError($res = $smtp->rcptTo($to))) {
die("Unable to add recipient <$to>: " . $res->getMessage() . "\n");
}
}

/* Set the body of the message. */
if (PEAR::isError($smtp->data($subj . "\r\n" . $body))) {
die("Unable to send data\n");
}

/* Disconnect from the SMTP server. */
$smtp->disconnect();

?>

Включен дебаг ($smtp->setDebug(true)) и он выдает такие данные:

DEBUG: Recv: 220 mail.farline.net ESMTP Postfix (Debian/GNU)
DEBUG: Send: EHLO localhost

DEBUG: Recv: 250-mail.farline.net
DEBUG: Recv: 250-PIPELINING
DEBUG: Recv: 250-SIZE 10240000
DEBUG: Recv: 250-ETRN
DEBUG: Recv: 250-STARTTLS
DEBUG: Recv: 250-AUTH LOGIN PLAIN
DEBUG: Recv: 250 8BITMIME
DEBUG: Send: MAIL FROM:<[email protected]>

DEBUG: Recv: 250 Ok
DEBUG: Send: RCPT TO:<[email protected]>

DEBUG: Recv: 554 <[email protected]>: Relay access denied
Unable to add recipient <[email protected]>: Invalid response code received from server

Что тут не так с получателем - я не могу понять, с почтовым сервером все нормально.
В нете вообще толком нет документации по PEAR::Net_SMTP, кроме того, что я нашел
http://cvs.php.net/viewvc.cgi/pear/Net_SMTP/docs/examples/basic.php?revision=1.1&view=markup

Может кто-то сталкивался с этой проблемой и поможет разобраться? Заранее благодарю!
 

RATA

Новичок
Да спс я понял!
Можно еще такой вопрос?

Не подскажете почему не работает mail.google.com?

-~{}~ 27.12.08 17:48:

Вот что я пытался проделать c почтой google.com:

<?
$path = '/usr/local/share/pear/';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once('Net/SMTP.php');


$host = 'smtp.gmail.com';
$from = '[email protected]';
$rcpt = array('[email protected]');
$subj = "Subject: Test Message\n";
$body = "Body Line 1\nBody Line 2";

/* Create a new Net_SMTP object. */
if (! ($smtp = new Net_SMTP($host,587))) {
die("Unable to instantiate Net_SMTP object\n");
}

$smtp->setDebug(true);

/* Connect to the SMTP server. */
if (PEAR::isError($e = $smtp->connect(10))) {
die($e->getMessage() . "\n");
}

/* Send the 'MAIL FROM:' SMTP command. */
if (PEAR::isError($smtp->mailFrom($from))) {
die("Unable to set sender to <$from>\n");
}

/* Address the message to each of the recipients. */
foreach ($rcpt as $to) {
if (PEAR::isError($res = $smtp->rcptTo($to))) {
die("Unable to add recipient <$to>: " . $res->getMessage() . "\n");
}
}

/* Set the body of the message. */
if (PEAR::isError($smtp->data($subj . "\r\n" . $body))) {
die("Unable to send data\n");
}

/* Disconnect from the SMTP server. */
$smtp->disconnect();

?>


Дебаг выдал следующий результат:

DEBUG: Recv: 220 mx.google.com ESMTP x26sm14618362ugc.9
DEBUG: Send: EHLO localhost

DEBUG: Recv: 250-mx.google.com at your service, [91.189.82.81]
DEBUG: Recv: 250-SIZE 35651584
DEBUG: Recv: 250-8BITMIME
DEBUG: Recv: 250-STARTTLS
DEBUG: Recv: 250 ENHANCEDSTATUSCODES
DEBUG: Send: MAIL FROM:<[email protected]>

DEBUG: Recv: 530 5.7.0 Must issue a STARTTLS command first. x26sm14618362ugc.9
Unable to set sender to <[email protected]>


В нете вычитал что google использует не 25 порт , а 587.
 

RATA

Новичок
А может кто-то дать полный развернутый ответ?

В нете пишут что нужна авторизация - но как ее сделать?

to Mr. Max - ты мне ничем не помог((
 

Mr_Max

Первый класс. Зимние каникулы ^_^
Команда форума
Открываем ссылку, нажимаем Ctrl+F Auth
Ы?
 
Сверху