OxyScripts.com
Menu spacer Home Tutorials Articles Code Forums irc.freenode.net #oxyscripts
Main (PHP)
Home Forums PHP News PHP Tutorials Articles PHP Code Snippets Contact Us Sysadmin Resources Books Template Shop
3rd Party Streams
SlashDot PHPDeveloper.org PHP.Net
Resources
PHP Manual MySQL Manual Smarty Manual PEAR Manual PHP-GTK Manual Symfony Manual
Code Snippets
Authentication Database Graphics HTTP Miscellaneous Time/Date
Affiliates
Scripts TutorialMan TutorialGuide CodingForums.com PHP Scripts Cheap Web Hosting Affordable Web Hosting Dreamweaver Templates

Search This Site :     PHP Function Reference :
 
Mail::send()

Mail::send()

Mail::send() -- sends a mail

Description

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

Parameter

  • mixed $recipients - an array or a string with comma separated recipients.

  • array $headers - an associative array of headers. The header name is used as key and the header value as value.

  • string $body - the body of the email.

Return value

boolean - TRUE or a PEAR_Error object, if fails

Throws

Table 36-1. Possible PEAR_Error values

Mailer driverError codeError messageReasonSolution
sendmail/smtpNULL "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.
smtpNULL "unable to instantiate Net_SMTP object" Failure in class creation Reinstall/update the Net_SMTP package.
smtpNULL "unable to connect to smtp server host:port" Connect to SMTP server failed Check $param['port'] and $param['host'] entries in your Mail::factory() call.
smtpNULL "unable to authenticate to smtp server" 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.
smtpNULL "unable to identify smtp server" Start request to SMTP server failed Check the RFC-compliances of the SMTP server to connect.
smtpNULL "unable to set sender to from" Sending the from address failed Check the RFC-compliances of the from address and the server connnectivity.
smtpNULL "unable to add recipient recipient:error code " Sending of recipient address failed Check the RFC-compliances of the recipient address and the server connnectivity.
smtpNULL "unable to send data" Body of the mail message could not send Check the RFC-compliances of the message body and the server connnectivity.

Note

This function can not be called statically.

Example

<?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);
?>
 
   Print this page

Top Sponsor
Symantec\'s Norton SystemWorks 2006
Sponsors
CA
Sponsors
AdWords Dominator 125*125
Advertisting

Affiliates
VertexTemplates PHPFreaks CodeWalkers StarGeek DevScripts CGI & PHP Scripts PHP CMS

Shopping Rebates   Sell It 4 You   Flash Page Counters   Get Insured
GPS Tracking Service   Charity Donate Info   Web Site Hosting   VOIP Service

Privacy Policy | Links | Site Map | Advertising

All content on OxyScripts.com is (©)2002-2007

 
Powered by Adrastea - Version 1.0.0. Copyright © Rune Solutions, 2004-2005