Home arrow PHP arrow Page 5 - Managing Email

Sending Email - PHP

If you want to write PHP scripts that handle email, there are a few things you need to understand first. This article, the first of two parts, introduces you to these concepts. It is excerpted from chapter 8 of the Zend PHP Certification Study Guide, written by Zend Technologies (Sams; ISBN: 0672327090).

TABLE OF CONTENTS:
  1. Managing Email
  2. MX Records
  3. Other Emerging Technologies
  4. Preparing PHP
  5. Sending Email
By: Sams Publishing
Rating: starstarstarstarstar / 6
November 09, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Use the PHP function mail() to send an email message from a PHP script.

The first parameter of the mail() function is the email address to send the email message to.

Assuming that you are running your PHP script on the server that is the MTA for the example.com email domain, and that there is a local user called fred, all of these are valid email addresses:

  • fred

    The MTA thinks you are trying to send an email to the local user fred.

  • fred@example.com

    This is the normal form for an email address, and the one that you are probably most familiar with.

  • fred @ example.com

    The MTA will automatically collapse the whitespace in the email address.

    Although perfectly legal, email addresses with whitespace are seldom seen today.

  • "Fred Bloggs" <fred@example.com>

    The MTA will automatically extract the fred@example.com from between the angular brackets.

    The entire string will be added as is to the From: line of the email message.

    Note that the double quotes are importantódo not leave them out.

Sending an Email to More Than One Recipient

Add additional addresses to the to parameter. Separate them by a comma and a space:

fred, joe@example.com, "Jane Doe"
<jane.doe@example.com>

If you want to cc: or bcc: an email to someone, do this by adding additional headers to your email.

Please check back next week for the conclusion of this article.



 
 
>>> More PHP Articles          >>> More By Sams Publishing
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: