Home >Backend Development >PHP Tutorial >Automatically send emails with PHP_PHP tutorial
Automatically send emails using this classhttp://bbs.php100.com/read-htm-tid-121431.html
Because the php version he used is older, he used the functions ereg_replace() and ereg()
Solution
1ereg_replace() function, replace it with the strtr() function
The syntax differences are as follows:
Detailshttp://www.php.net/manual/zh/function.ereg-replace.php
Detailshttp://www.w3school.com.cn/php/func_string_strtr.asp
2ereg() function, replace it with the preg_match() function
Linkhttp://blog.163.com/yanli_xu/blog/static/1363672912011420101820393/
preg_match() FunctionSyntaxhttp://www.php.net/manual/zh/function .preg-match.php
After modification, the complete code is as follows
[Mail class] sm.class.php
smtp( = "", = 25, = ,, ->debug = ->smtp_port = ->relay_host = ->time_out = 30; ->auth = ; ->user = ->pass = ->host_name = "localhost"; ->log_file = "" ->sock = sendmail(, , = "", = "", , = "", = "", = "" = ->get_address(->strip_comment( = (, "(^|(rn))(.)", "1.3" .= "MIME-Version:1.0rn" (=="HTML" .= "Content-Type:text/htmlrn" .= "To: ".."rn" ( != "" .= "Cc: ".."rn" .= "From: <"..">rn" .= "Subject: ".."rn" .= .= "Date: ".("r")."rn" .= "X-Mailer:By Redhat (PHP/".().")rn" (, ) = (" ", .= "Message-ID: <".("YmdHis", ).".".(