Home  >  Article  >  Backend Development  >  Sending emails using Socket 4_PHP Tutorial

Sending emails using Socket 4_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:28:271179browse

Implementation of send_mail class
Now let’s introduce the send mail class I wrote. With the above preparatory knowledge, the following is the implementation.
Member variables of the class
var $lastmessage; //Record the last response message returned
var $lalastact; //The last action, in string form
var $welcome; //Used in HELO Later, users are 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 the executed command. When an error occurs, the user can use them. For testing needs, I also defined the $debug variable. When its value is true, some execution information will be displayed during the running process, otherwise there will be no output. $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 The constructor mainly completes the determination and setting of some initial values. $welcome is used in the HELO directive to tell the server the user's name.
The HELO command requires a machine name, but it can be used without it. If the user does not provide $welcome, the local machine name is automatically searched.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531784.htmlTechArticleImplementation of send_mail class Now I will introduce the sending mail class I wrote. With the above preparatory knowledge, the following is the implementation. Class member variable var $lastmessage; //Record the last...
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