Introduction: This is a PHP script in phpmailer IIS. It uses Gmail to send emails to PhP details page. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 325742 'rolling = 'no'>
PHP scripts in phpmailer IIS use Gmail to send emails to PhP
Setting up a PHP environment in Windows is troublesome. Therefore, PHP components encapsulated by others are generally used, and phpnow is used in mingchennet.com.
Mingchen network mingchennet.com uses the Google-powered enterprise Post Office Standard Edition. Google uses a secure SSL-encrypted SMTP protocol. Therefore, when connecting to Gmail in PHP, you need to make some settings to support SSL. The test conclusion of mingchennet.com is given here.
Use iprober. PHP probes are used to check the PHP environment. By default, phpnow does not support socket installation. If there is no problem connecting to a common SMTP server, the SMTP server with SSL encryption will prompt: SMTP error: cocould not connect to SMTP host. In this case, open the PHP socket and OpenSSL components and modify the PHP. ini configuration file. The phpnow configuration file PHP. INI is located in the C: \ Windows Directory, rather than under c: \ programe files \ php_iis!
First, open the c: \ windows \ PHP. ini file, remove the semicolon before the following two rows, and save.
; Extension = php_sockets.dll
; Extension = php_openssl.dll
Copy c: \ Program Files \ php_iis \ PHP \ libeay32.dll and ssleay32.dll to the C: \ windows \ system32 directory and restart IIS.
OK. Use phpmailer to test your Gmail.
1.
<? PHP
2.
Include ("class. phpmailer. php"); // load the main class of phpmailer. In general, set the phpmailer path.
3.
Include ("class. SMTP. php"); // load the SMTP class. Generally, set the phpmailer path.
4.
$ Mail = new phpmailer ();
5.
$ Mail-> issmtp (); // use SMTP
6.
$ Mail-> smtpsecure = "SSL ";
7.
$ Mail-> host = "smtp.gmail.com ";
8.
$ Mail-> Port = 465; // SMTP port number of Gmail
9.
$ Mail-> smtpauth = true; // enable SMTP authentication
10.
$ Mail-> username = "mingchennet@gmail.com"; // Gmail Username
11.
$ Mail-> Password = "password"; // Gmail Password
12.
$ Webmaster_email = "mingchennet@gmail.com"; // reply to this address
13.
$ Email = "mingchennet@gmail.com"; // recipient
14.
$ Name = "tomorrow morning network"; // Recipient Name
15.
$ Mail-> from = $ webmaster_email;
16.
$ Mail-> fromname = "tomorrow morning network ";
17.
$ Mail-> addaddress ($ email, $ name );
18.
$ Mail-> addreplyto ($ webmaster_email, "mingchen network ");
19.
$ Mail-> wordwrap = 50; // set word wrap
20.
// $ Mail-> addattachment ("/var/tmp/file.tar.gz"); // Attachment 1
21.
// $ Mail-> addattachment ("/tmp/image.jpg", "new.jpg"); // Attachment 2
22.
$ Mail-> ishtml (true); // send in HTML
23.
$ Mail-> subject = "this is the subject ";
24.
$ Mail-> body = "Hi,
25.
This is the html body "; // html body
26.
$ Mail-> altbody = "this is the body when user views in plain text format"; // body for plain text
27.
If (! $ Mail-> send ())
28.
{
29.
Echo "Mailer error:". $ mail-> errorinfo;
30.
}
31.
Else
32.
{
33.
Echo "message has been sent ";
34.
}
35.
?>
More articles about "using Gmail to send emails to PHP scripts under phpmailer IIS"
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/325742.html pageno: 13.