WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : mail -- send mail
Categories : PHP, PHP Functions, Mail Update Picture
documentation group PHP
Date : May 22nd 1999
Grade : 2 of 5 (graded 3 times)
Viewed : 7577
File : No file for this code example.
Images : No Images for this code example.
Search : More code by documentation group PHP
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

Description

Description

</H2
><DIV
CLASS="funcsynopsis"
><A
NAME="AEN22529"
></A
><P
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>bool <B
CLASS="function"
>mail</B
></CODE
> (string to, string subject, string message [, string
additional_headers [, string
additional_parameters]])</CODE
></P
><P
></P
></DIV
><P
>&#13; <B
CLASS="function"
>Mail()</B
> automatically mails the message specified
in <TT
CLASS="parameter"
><I
>message</I
></TT
> to the receiver specified in
<TT
CLASS="parameter"
><I
>to</I
></TT
>. Multiple recipients can be specified by
putting a comma between each address in <TT
CLASS="parameter"
><I
>to</I
></TT
>.
</P
><P
>&#13; <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN22551"
></A
><P
><B
>Example 1. Sending mail.</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13;mail("rasmus@lerdorf.on.ca", "My Subject", "Line 1\nLine 2\nLine 3");
</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></P
><P
>&#13; If a fourth string argument is passed, this string is inserted at
the end of the header. This is typically used to add extra
headers. Multiple extra headers are separated with a newline.
</P
><P
>&#13; If the fifth parameter is supplied, PHP will add this data
to the call to the mailer. This is useful when setting the
correct Return-Path header when using sendmail.
</P
><P
>&#13; <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN22557"
></A
><P
><B
>Example 2. Sending mail with extra headers.</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13;mail("nobody@aol.com", "the subject", $message,
"From: webmaster@$SERVER_NAME\nReply-To: webmaster@$SERVER_NAME\nX-Mailer: PHP/" .version());
</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
With the fifth parameter you can set additional command line parameters to
the actual mailer. In the example below we set the correct Return-Path
header for sendmail. Normally sendmail will add the X-Authentication-Warning
header when using the -f parameter, because the webserver user is probably
not a member of the trusted users. To suppress this warning, you should add
the web server user to the trusted users in your sendmail config file.
<TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN22560"
></A
><P
><B
>Example 3. Sending mail with extra headers and setting an additional command line parameter.</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13;mail("nobody@aol.com", "the subject", $message,
"From: webmaster@$SERVER_NAME", "-fwebmaster@$SERVERNAME");
</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
You can also use fairly simple string building techniques to
build complex email messages.
<TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN22563"
></A
><P
><B
>Example 4. Sending complex email.</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13;/* recipients */
$recipient .= "Mary &#60;mary@u.college.edu&#62;" . ", " ; //note the comma
$recipient .= "Kelly &#60;kelly@u.college.edu&#62;" . ", ";
$recipient .= "ronabop.net";

/* subject */
$subject = "Birthday Reminders for August";

/* message */
$message .= "The following email includes a formatted ASCII table\n";
$message .= "Day \t\tMonth \t\tYear\n";
$message .= "3rd \t\tAug \t\t1970\n";
$message .= "17rd\t\tAug \t\t1973\n";

/* you can add a stock signature */
$message .= "--\r\n"; //Signature delimiter
$message .= "Birthday reminder copylefted by public domain";

/* additional header pieces for errors, From cc's, bcc's, etc */

$headers .= "From: Birthday Reminder &#60;birthday.net&#62;\n";
$headers .= "X-Sender: &#60;birthday.net&#62;\n";
$headers .= "X-Mailer: PHP\n"; // mailer
$headers .= "X-Priority: 1\n"; // Urgent message!
$headers .= "Return-Path: &#60;birthday.net&#62;\n"; // Return path for errors

/* If you want to send html mail, uncomment the following line */
// $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type

$headers .= "cc:birthdayarchive.net\n"; // CC to
$headers .= "bcc:birthdaycheck.net, birthdaygifts.net\n"; // BCCs to

/* and now mail it */
mail($recipient, $subject, $message, $headers);
</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
</P
></DIV
>




Email Class
Categories : PHP, Mail, PHP Classes
Protect your email links from being spidered by spam email robots!
Categories : PHP, Security, Mail, Email
Data Retrieve from mailbox and generate the SQL Syntax
Categories : PHP, IMAP, Mail
XPertMailer - Sends TRUE Mails
Categories : PHP, Mail, SMTP, PHP Classes
Tell a friend script :)
Categories : PHP, Mail
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Simple Maiing list with newsletter support
Categories : PHP, PHP Classes, Mail
tinySendMail and tinySockMail functions for generating SMTP mail within PHP
Categories : PHP, Mail, SMTP
Convert text to 'quoted printable' without the IMAP package installed.
Categories : PHP, Mail, IMAP
Sending mail to a mailing list and showing progress
Categories : PHP, Mail, Beginner Guides
ezmlm_hash -- Calculate the hash value needed by EZMLM
Categories : PHP, PHP Functions, Mail
send php mail with form data and attachment.
Categories : PHP, Email, Mail, Form Processing
Using this script anyone can easily get a form result to his/her mailbox. You can use this script for any form 2 mail purpose.
Categories : PHP, Mail, Form Processing
Password reminder
Categories : PHP, PHP Classes, Databases, MySQL, Mail
This is Yet Another Sql Abstraction Library. Include it in your script and you can use the most important SQL functions without worrying about the SQL backend.
Categories : Databases, PHP, ODBC, MySQL, PostgreSQL