PHP uses pear to implement the mail Send feature in Windows environment Configuration pear,pearmail_php Tutorial

Source: Internet
Author: User
Tags pear php email

PHP uses pear to implement the mail Send function in Windows environment configuration Pear,pearmail

PHP email can be used with its own mail () function, but this function is very bad, you need to configure the mail server, and does not support SMTP authentication, in many cases does not work properly. Find a code to send an email, but always error, I am here with the Pear Mail class, using SMTP to send mail.

First install, I push Chen with the latest version of the PHP5, because I have a lot of problems with PHP4, mostly because the package of the class version is too high, and PHP4 incompatible with the original.
Installation method:
1. In the PHP directory, double-click Go-pear.bat.
2. Follow the prompts to enter some settings information, mainly to ask for direct access to the outside network, or with the agent, if no proxy server directly enter, I am directly press ENTER.
3. Then you will be prompted for some packages and PHP bindings, select Y.
4. Then install the basic package and prompt the installation to succeed, as simple as that.
5. Open the php.ini file under the Windows directory and look for the following places:
; UNIX: "/path1:/path2"
; include_path = ".:/ Php/includes "
; Windows: "\path1;\path2"
; include_path = ".; C:\php\includes "

Remove the comment from the last line, and then change the back path to your pear path, for example:
include_path = ".; C:\php\pear\ "
Save the php.ini, and then restart Apache.

Now that the pear is OK, the class we want to use is placed under the Pear folder in the PHP directory, but there are not many available classes, we are going to download and install it online.

You can find the Pear.bat file in your PHP root directory (This is what happens when you perform the installation above), which is the command to manage pear, use it in cmd, set the environment variable path, or double-click the generated ev_xxx. REG file. Some of its command functions are as follows:
1. Installation:

To install a Pear class library from the network:
Pear Install PackageName

Download packages but uncomfortable:
Pear Download PackageName
Pear Download-all

Install the downloaded package:
Pear Install filename.tgz

2. List:

List of all available pear class libraries on the Pear website at present:
Pear remote-list

List Installed packages:
Pear List

List the package that can be upgraded:
Pear List-upgrades

3. Update (UPGRADE):

Update package:
Pear Upgrade PackageName
Pear Upgrade-all

4. Removal:

Remove the installed package:
Pear Uninstall PackageName

We go from cmd to php directory, execute pear install mail
If the installation process prompts that some libraries are not installed, continue to install the libraries

This continues to install:

Out some information, will be prompted to install the success, when the pear directory more than a mail directory, at the same time there is a mail.php, this is the one we will refer to the file.
Below is the code we use to send e-mails:

<?require_once ' mail.php '; flush (); $conf [' Mail '] = Array (    ' host ' = ' ',  // SMTP server address, can use IP address or domain name    ' auth '   = True,         //true indicates SMTP server needs authentication, false code does not need    ' username ' = ' guanhf844 ',//      username     ' password ' = ' your password '/' password ',        $headers [' from ']  = ' ';       Sending address $headers[' to ']   = ' ';       Mail address $headers[' Subject ' = ' test mail send by PHP ';     Message title $mail_object = &mail::factory (' smtp ', $conf [' Mail ']);  $body = ' <<< MSG                    Hello World!!! MSG ';//message body $mail_res = $mail _object->send ($headers [' to '], $headers, $body);    Send if (Pear::iserror ($mail _res)) {             //Detect error Die  ($mail _res->getmessage ());} Echo ' Send finished. ';? >

Test sent successfully, the speed is very fast, other mailboxes are not tested.

The above is PHP using pear to implement the mail send function of all the code, I hope that everyone's learning is helpful.

Articles you may be interested in:

    • A class that sends mail through SMTP in PHP, tested by
    • Code that uses SMTP to send mail under PHP
    • Phpmailer message class using to send mail methods
    • PHP Mail failed to send mail through SMTP of Windows solution
    • PHP uses SMTP to send mail samples that support attachments
    • PHP implements an SMTP mail-sending class that supports SSL connections
    • How PHP uses Pear's own mail class library to send mail
    • PHP uses pear to send mail (Windows environment)
    • PHP uses PEAR_SMTP to send mail true techarticle PHP uses pear to implement the mail Send function in Windows environment configuration pear,pearmail PHP e-mail can be used with its own mail () function, but this function is not good to make, need to configure the mail server, and ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.