Use Socket to send email 1

Source: Internet
Author: User
In the several PHP homepage spaces applied by the author, there are not many mail functions available. after The mail () function is called, there will be no more details. However, emails play an increasingly important role in online life. Do you think that online worms do not receive emails and can be called real worms? I don't want to talk about the role of the email, but SyntaxHighlighter. all ();

In the several PHP homepage spaces applied by the author, there are not many mail functions available. after The mail () function is called, there will be no more details. However, emails play an increasingly important role in online life. Do you think that online worms do not receive emails and can be called real worms? I don't want to talk about the role of the email, but what if the home page does not support mail () sending? I also thought about sending emails through socket, but I am not familiar with socket programming using php. In addition, sending emails requires SMTP protocol and reading a lot of English, so I have never studied it. One day I finally found an article about sending emails through socket programming. I copied it as a treasure and transformed it into a usable php class for your use. The original article is just a simple example, and there are still some errors. after many experiments and transformations, I finally changed it to a direct socket, class for sending emails to a specified mailbox. if you combine the class with the previous article about sending MIME, you can send emails on websites that do not support the mail () function. Because the mail sending process takes time, it may not be the same as the mail () processing mechanism, so the speed is slower, but it can solve the urgent need for the mail sending function, you can also use php for socket programming. The following describes the implementation principles of this class, and explains some basic SMTP knowledge.
Socket programming
I declare to everyone that I am not a TCP/IP programming expert, so here I just give my understanding and experience.
Use the fsockopen function to open an Internet connection. function syntax format:
Int fsockopen (string hostname, int port, int [errno], string [errstr], int [timeout]);
I don't want to talk about the parameter. the port number is 25 because the SMTP protocol is used. After a successful connection is opened, a socket handle is returned, which can be the same as a file handle. Available operations include fputs (), fgets (), feof (), and fclose.
This is a simple introduction.

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.