Mail::send()

Mail::send() -- sends a mail

Synopsis

require_once 'Mail.php';

mixed send (mixed $recipients, array $headers, string $body)

Описание

Sends a mail. The send()-function is provided by the object returned from factory()

Параметр

Возвращаемое значение

boolean - TRUE or a PEAR_Error object, if fails

Throws

Таблица 47-1. Возможные значения PEAR_Error

Mailer driverError codeError messageReasonSolution
sendmailNULL "No from address given." The $headers array requires at least a from entry. Add a From header:
$headers['From'] = 'mymail@example.com';
sendmailNULL "From address specified with dangerous characters." The from entry in the $headers array contains one ore more characters which could be non-RFC compliant Check the given from address for characters like: spaces or ; or & or ` (backtick)
sendmailNULL "sendmail [path to sendmail] not executable" The path to sendmail program is not correct. No sendmail executable found there. Check the $param['sendmail_path'] entry in your Mail::factory() call. If you use another mailer then sendmail, ie. qmail, check installation of the mailer. Normally it should includes a sendmail wrapper.
sendmailNULL "sendmail returned error code code" Sendmail returns a error, which must be handled by use. See the documention of your mailer programm.
smtpPEAR_MAIL_SMTP_ERROR_CREATE "Failed to create a Net_SMTP object" Failure in class creation Reinstall/update the Net_SMTP package.
smtpPEAR_MAIL_SMTP_ERROR_CONNECT "Failed to connect to host:port" Connect to SMTP server failed Check $param['port'] and $param['host'] entries in your Mail::factory() call.
smtpPEAR_MAIL_SMTP_ERROR_AUTH "method authentication failure" Authentication failed Check $param['auth'], $param['username'] and $param['password'] entries in your Mail::factory() call. Ensure to use the correct authentication method for the SMTP server.
smtpPEAR_MAIL_SMTP_ERROR_FROM "No From: address has been provided" The $headers array requires at least a from entry. Add a From header:
$headers['From'] = 'mymail@example.com';
smtpPEAR_MAIL_SMTP_ERROR_SENDER "Failed to set sender: from" Setting the sender address failed Check the RFC-compliances of the sender address and the server connnectivity.
smtpPEAR_MAIL_SMTP_ERROR_RECIPIENT "Failed to add recipient: recipient " Sending of recipient address failed Check the RFC-compliances of the recipient address and the server connnectivity.
smtpPEAR_MAIL_SMTP_ERROR_DATA "Failed to send data" Body of the mail message could not send Check the RFC-compliances of the message body and the server connnectivity.

Заметка

Эта функция не должна вызываться статически.

Пример

<?php
include('Mail.php');

$recipients = 'joe@example.com';

$headers['From']    = 'richard@example.com';
$headers['To']      = 'joe@example.com';
$headers['Subject'] = 'Test message';

$body = 'Test message';

$params['sendmail_path'] = '/usr/lib/sendmail';

// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('sendmail', $params);

$mail_object->send($recipients, $headers, $body);
?>

См. также

Mail::factory()


HIVE: All information for read only. Please respect copyright!
Hosted by hive йца: йХЕБЯЙЮЪ ЦНПНДЯЙЮЪ АХАКХНРЕЙЮ