Use Socket to send email 4

Source: Internet
Author: User

Send_mail class implementation
Now we will introduce the mail class I have compiled. With the above preparation knowledge, the following is the implementation.
Class member variables
Var $ lastmessage; // record the last response
Var $ lastact; // The final action, in the string format
Var $ welcome; // used after HELO. welcome
Var $ debug; // whether to display debugging information
Var $ smtp; // smtp Server
Var $ port; // smtp port number
Var $ fp; // socket handle
Among them, $ lastmessage and $ lastact are used to record the last response information and executed commands. When an error occurs, you can use them. For testing purposes, I also defined the $ debug variable. When its value is true, some execution information is displayed during the running process; otherwise, no output is provided. $ Fp is used to save the opened socket handle.
Class Construction
Function send_mail ($ smtp, $ welcome = "", $ debug = false)
{
If (empty ($ smtp) die ("SMTP cannt be NULL! ");
$ This-$ # @ 62; smtp = $ smtp;
If (empty ($ welcome ))
{
$ This-$ # @ 62; welcome = gethostbyaddr ("localhost ");
}
Else
$ This-$ # @ 62; welcome = $ welcome;
$ This-$ # @ 62; debug = $ debug;
$ This-$ # @ 62; lastmessage = "";
$ This-$ # @ 62; lastact = "";
$ This-$ # @ 62; port = "25 ";
}
This constructor mainly determines and sets some initial values. $ Welcome is used in the HELO command to tell the server user's name.
The HELO command must be a machine name. If $ welcome is not provided, the local machine name is automatically searched.


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.