This is a discussion on PHP Mail functions within the PHP Programming forums, part of the Web Development category; Hi Buddies Am new to the PHP Mail function. If any one know about that PHP Mail function. Please explain ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, For the Mail functions to be available, PHP must have access to the sendmail binary on your system during compile time. If you use another mail program, such as qmail or postfix, be sure to use the appropriate sendmail wrappers that come with them. PHP will first look for sendmail in your PATH, and then in the following: /usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib. It's highly recommended to have sendmail available from your PATH. Also, the user that compiled PHP must have permission to access the sendmail binary.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| The sendmail program can be found, usually /usr/sbin/sendmail or /usr/lib/sendmail. configure does an honest attempt of locating this one for you and set a default, but if it fails, you can set it here. Systems not using sendmail should set this directive to the sendmail wrapper/replacement their mail system offers, if any. For example, Qmail users can normally set it to /var/qmail/bin/sendmail or /var/qmail/bin/qmail-inject. qmail-inject does not require any option to process mail correctly. This directive works also under Windows. If set, smtp, smtp_port and sendmail_from are ignored and the specified command is executed.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| There is no installation needed to use these functions; they are part of the PHP core. Just we have to enable in php.ini with some variables
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| The following variables are to changed according to your requirement SMTP Used under Windows only: DNS name or IP address of the SMTP server PHP should use for mail sent with the mail() function. smtp_port Used under Windows only: Number of the port to connect to the server specified with the SMTP setting when sending mail with mail(); defaults to 25. Only available since PHP 4.3.0. sendmail_from Which "From:" mail address should be used in mail sent from PHP under Windows. sendmail_path Where the sendmail program can be found, usually /usr/sbin/sendmail or /usr/lib/sendmail. configure does an honest attempt of locating this one for you and set a default, but if it fails, you can set it here.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| For send normal mail we use mail() Syntax Code: bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| From the above syntax to - Receiver, or receivers of the mail. examples are: user@example.com user@example.com, anotheruser@example.com User <user@example.com> User <user@example.com>, Another User <anotheruser@example.com>
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| subject - Subject of the email to be sent. message- Message to be sent. Each line should be separated with a LF (\n). Lines should not be larger than 70 characters.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| In the message area for Windows When PHP is talking to a SMTP server directly, if a full stop is found on the start of a line, it is removed. To counter-act this, replace these occurrences with a double dot. For example PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| additional_headers - String to be inserted at the end of the email header. This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n).
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini. Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. If messages are not received, try using a LF (\n) only. Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used).
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| additional_parameters - The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option. The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a 'X-Warning' header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Using mail() to send a simple email: PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| In PHP 4.3.0 (Windows only) All custom headers (like From, Cc, Bcc and Date) are supported, and are not case-sensitive. (As custom headers are not interpreted by the MTA in the first place, but are parsed by PHP, PHP < 4.3 only supported the Cc header element and was case-sensitive).
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Example Sending mail with extra headers The addition of basic headers, telling the MUA the From and Reply-To addresses PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Hi, Example for sending mail with an additional command line parameter The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path. PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to send mail from php? | sureshbabu | PHP Programming | 4 | 04-03-2008 02:21 AM |
| How to Send mail using dot net ...? | a.deeban | ASP and ASP.NET Programming | 9 | 01-17-2008 09:20 PM |
| e-mail from an ASP.NET | Arun | ASP and ASP.NET Programming | 3 | 09-20-2007 10:28 PM |
| What are Virtual Functions? How to implement virtual functions in "C"? | Sabari | C and C++ Programming | 4 | 09-10-2007 11:35 PM |
| mail function | vijayanand | PHP Programming | 2 | 08-03-2007 12:55 AM |