Use Socket to send an email (7) _ PHP Tutorial

Source: Internet
Author: User
Tags ereg
Use Socket to send an email (7 ). The following is a real secret for sending mail B. You should check it carefully. :) 1 functionsend ($ to, $ from, $ subject, $ message) 2 {3 Connect to server 4 $ this-$ # @ 62; lastactconnect; 5 B> Mail sending
The following are the real secrets. you should check them carefully. :)
1 function send ($ to, $ from, $ subject, $ message)
2 {
3 // connect to the server
4 $ this-$ # @ 62; lastact = "connect ";
5 $ this-$ # @ 62; show_debug ("Connect to SMTP server:". $ this-$ # @ 62; smtp, "out ");
6 $ this-$ # @ 62; fp = fsockopen ($ this-$ # @ 62; smtp, $ this-$ # @ 62; port );
7 if ($ this-$ # @ 62; fp)
8 {
9 set_socket_blocking ($ this-$ # @ 62; fp, true );
10 $ this-$ # @ 62; lastmessage = fgets ($ this-$ # @ 62; fp, 512 );
11 $ this-$ # @ 62; show_debug ($ this-$ # @ 62; lastmessage, "in ");
12 if (! Ereg ("^ 220", $ this-$ # @ 62; lastmessage ))
13 {
14 return false;
15}
16 else
17 {
18 $ this-$ # @ 62; lastact = "HELO". $ this-$ # @ 62; welcome ."";
19 if (! $ This-$ # @ 62; do_command ($ this-$ # @ 62; lastact, "250 "))
20 {
21 fclose ($ this-$ # @ 62; fp );
22 return false;
23}
24 $ this-$ # @ 62; lastact = "mail from: $ from "."";

25 if (! $ This-$ # @ 62; do_command ($ this-$ # @ 62; lastact, "250 "))
26 {
27 fclose ($ this-$ # @ 62; fp );
28 return false;
29}
30 $ this-$ # @ 62; lastact = "rcpt to: $ "."";
31 if (! $ This-$ # @ 62; do_command ($ this-$ # @ 62; lastact, "250 "))
32 {
33 fclose ($ this-$ # @ 62; fp );
34 return false;
35}
36 // send the body
37 $ this-$ # @ 62; lastact = "DATA ";
38 if (! $ This-$ # @ 62; do_command ($ this-$ # @ 62; lastact, "354 "))
39 {
40 fclose ($ this-$ # @ 62; fp );
41 return false;
42}
43 // process the Subject header
44 $ head = "Subject: $ subject ";
45 if (! Empty ($ subject )&&! Ereg ($ head, $ message ))
46 {
47 $ message = $ head. $ message;
48}
49 // process the From header
50 $ head = "From: $ from ";
51 if (! Empty ($ from )&&! Ereg ($ head, $ message ))
52 {
53 $ message = $ head. $ message;
54}
55 // process the To header
56 $ head = "To: $ ";
57 if (! Empty ($ )&&! Ereg ($ head, $ message ))
58 {
59 $ message = $ head. $ message;
60} <

Http://www.bkjia.com/PHPjc/532378.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/532378.htmlTechArticleb> mail processing below is the real secret, you can look at carefully. :) 1 function send ($ to, $ from, $ subject, $ message) 2 {3 // connect to server 4 $ this-$ # @ 62; lastact = "connect "; 5...

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: info-contact@alibabacloud.com 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.