Home >Backend Development >PHP Tutorial >Configuration of sending emails with PHP_PHP tutorial

Configuration of sending emails with PHP_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:49:411088browse

I want to use PHP to send emails (yuan_ping@163.com to nnnnyyyy@21cn.com) and wrote a program according to some books, but it failed to run. May I ask why?


//Declare the email address as the receiving email address
$mailTo="nnnnyyyy@21cn.com";

//Email subject:
$mailSubject="Just a test Mail!";


//Email text:
$mailBody="This is a test of PHP`s mail function.";
$mailBody="It was generated by PHP version.";
$mailBoyd.=phpversion();


//Email header:
$mailHeaders="From:yuan_ping@163.com";


//Send email
if (mail($mailto,$mailSubject,$mailBody,$mailHeaders))
{
echo "Mail successfully sent!";
}
else
          {
echo "Error in sending mail!";
}
?>


Sending was unsuccessful.


Need to configure the smtp server


Windows 2000 users


Install and set up the server


Windows XP and 2000 have the function of building an SMTP server, but they are generally not installed yet. Select "Control Panel→Add/Remove Programs→Add/Remove Windows Components" to pop up the "Windows Components Wizard" dialog box. Double-click the "Internet Information Services (IIS)" item in it to open the detailed selection item and select "SMTP Service". ”, press “OK”, insert the Windows XP installation disk to install



After installing the SMTP server, select "Control Panel → Performance and Maintenance → Management Tools → Internet Information Services" to open the Internet Information Services settings window. Click the local computer name on the left side of the window and expand the local computer directory. You can see that there are two branches. "Wed Site" and "Default SMTP Virtual Server". Right-click the "Default SMTP Virtual Server" and select "Properties" to open the "Default SMTP Virtual Server Properties" window.


The "General" tab mainly sets the IP address. Click the IP address drop-down item and select "127.0.0.1", which means it points to the local computer IP address. Use the default for other items. If you are accessing the LAN and have a fixed IP address, then the IP address should be selected accordingly



Set access permissions in the Access tab. Click "Authentication" and select "Anonymous Access", which means that any user can send, and there is no need to select the other two items; click "Connect" in "Connection Control" and "Interrupt" in "Middle Restrictions", select " Except for the following list" means that access to all users is allowed.


Set mail transmission conditions and restrictions in the "Mail" tab. The four options such as "Limit mail size to" can use the default values ​​and do not need to be changed;


"Send a copy of the non-delivery report to" can return unsuccessfully sent emails to the sender, and state the reason for the failure; "Bad Letter Directory" sets the location where emails that have not been successfully sent are stored.


Set the mail delivery time in the "Transport" option. There is no need to modify it here, use the default value; the "LDAP Routing" option is used to specify the directory server ID and attributes used by the server, and there is no need to start it here.


In the "Security" option, set the authorized users to use the sending server. The default user is "Administrators". You can click "Add" to add a user.


Once everything is set up, you have your own outgoing email server!

After SMTP is installed, you should be under WINDOW2K and you will find PHP. INI file under C:WINNT
Open and find the following lines
[mail function]
; For Win32 only.
SMTP = 10.0.0.9 -------》Replace with your IP, 10.0.0.9 is my IP :)


; For Win32 only.
sendmail_from = test@test.com ---》Sender information


Then restart APACHE

Excerpted from Jupiter Blue Dragon

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478313.htmlTechArticleI want to use PHP to send emails (yuan_ping@163.com to nnnnyyyy@21cn.com) according to some books I wrote a program, but it failed to run. May I ask why? ?php //Declare email address,...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn