Home Backend Development PHP Tutorial 稳定经得住考验的smtp发送邮件的类(请付上使用方法),万分感谢

稳定经得住考验的smtp发送邮件的类(请付上使用方法),万分感谢

Jun 13, 2016 pm 01:51 PM
gt header quot this

求一个稳定经得住考验的smtp发送邮件的类(请付上使用方法),万分感谢!
我找了几个,有的不能用,发不出,有的居然没有正文;
还有一个正文这些都有,但没发几封就说 "帐号已经被锁定 ",discuz\phpwind这些的邮件类又搞得太复杂,剥离不出来!

谢谢拉!!!
用mail函数和iis得smtp,它又老是说address   invalid!怎么改地址都不行: "aaa "   or   "aaa@163.com ",都是错得

如果比较大,lein_urg@163.com,请发到邮箱,谢谢!
发邮件者20分起哈,如果正确得话60分起!

------解决方案--------------------
class smtp
{
/* Public Variables */
var $smtp_port;
var $time_out;
var $host_name;
var $log_file;
var $relay_host;
var $debug;
var $auth;
var $user;
var $pass;

/* Private Variables */
var $sock;

/* Constractor */
function smtp($relay_host = " ", $smtp_port = 25,$auth = false,$user,$pass)
{
$this-> debug = FALSE;
$this-> smtp_port = $smtp_port;
$this-> relay_host = $relay_host;
$this-> time_out = 30; //is used in fsockopen()
$this-> auth = $auth;//auth
$this-> user = $user;
$this-> pass = $pass;
$this-> host_name = "localhost "; //is used in HELO command
$this-> log_file = " ";
$this-> sock = FALSE;
}

/* Main Function */
function sendmail($to, $from, $subject = " ", $body = " ", $mailtype, $cc = " ", $bcc = " ", $additional_headers = " ")
{
$mail_from = $this-> get_address($this-> strip_comment($from));
$body = ereg_replace( "(^|(\r\n))(\.) ", "\1.\3 ", $body);
$header .= "MIME-Version:1.0\r\n ";
if($mailtype== "HTML ")
{
$header .= "Content-Type:text/html\r\n ";
}
$header .= "To: ".$to. "\r\n ";
if ($cc != " ")
{
$header .= "Cc: ".$cc. "\r\n ";
}
$header .= "From: $from \r\n ";
$header .= "Subject: ".$subject. "\r\n ";
$header .= $additional_headers;
$header .= "Date: ".date( "r "). "\r\n ";
$header .= "X-Mailer:By Redhat (PHP/ ".phpversion(). ")\r\n ";
list($msec, $sec) = explode( " ", microtime());
$header .= "Message-ID: \r\n ";
$TO = explode( ", ", $this-> strip_comment($to));

if ($cc != " ")
{
$TO = array_merge($TO, explode( ", ", $this-> strip_comment($cc)));
}
if ($bcc != " ")
{
$TO = array_merge($TO, explode( ", ", $this-> strip_comment($bcc)));
}
$sent = TRUE;
foreach ($TO as $rcpt_to)
{
$rcpt_to = $this-> get_address($rcpt_to);
if (!$this-> smtp_sockopen($rcpt_to))
{
$this-> log_write( "Error: Cannot send email to ".$rcpt_to. "\n ");
$sent = FALSE;
continue;
}
if ($this-> smtp_send($this-> host_name, $mail_from, $rcpt_to, $header, $body))
{
$this-> log_write( "E-mail has been sent to \n ");
}
else
{
$this-> log_write( "Error: Cannot send email to \n ");
$sent = FALSE;
}
fclose($this-> sock);
$this-> log_write( "Disconnected from remote host\n ");
}
return $sent;

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1669
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

How does SpringBoot pass parameters in the Header through Feign calls? How does SpringBoot pass parameters in the Header through Feign calls? May 16, 2023 pm 08:38 PM

[SpringBoot] Passing parameters in the Header through Feign calls How to pass Header parameters through Feign Problem description When we use Feign to request the Api interface of another service in Spring Cloud, there is a need to pass the parameters in the Header. If no special processing is done, it will The parameters in the Header will be lost. Solution 1: Pass it through @RequestHeader(name="headerName"). For example: Feign is defined as follows @FeignClient(name="service-name")pub

What does linux header mean? What does linux header mean? Jul 18, 2023 pm 03:34 PM

The Linux header refers to the beginning of a file or data stream, which is used to contain metadata about the content. By correctly writing and using Header files, developers can better utilize system resources and improve code readability and Maintainability.

How to jump in php header How to jump in php header Dec 02, 2022 am 09:14 AM

How to implement jump in php header: 1. Use "Header("Location:$url");" syntax to implement jump; 2. Use if judgment to implement jump, with jump statements such as "if($_COOKIE[" u_type"]){ header('location:register.php'); } else{ setcookie('u_type','1','86400*360');".

How to use PHP header() method to adjust web pages How to use PHP header() method to adjust web pages Mar 28, 2023 pm 01:54 PM

PHP is a powerful programming language that can be used to create dynamic websites and web applications. One of the most powerful features is PHP’s header() method. In this article, we will explore how to use PHP’s header() method to adjust web pages.

What is the difference between html5 tag head and header? What is the difference between html5 tag head and header? Jan 17, 2022 am 11:10 AM

Differences: 1. The head tag is used to define the head of the document, which is a container for all head elements, and the header tag is used to define the header (introduction information) of the document; 2. All browsers support the head tag, and older versions of browsers None of the browsers support the header tag, and browsers such as IE9+ and above are required to support the header tag.

Complete list of PHP file download functions: analysis of file download examples of readfile, header, Content-Disposition and other functions Complete list of PHP file download functions: analysis of file download examples of readfile, header, Content-Disposition and other functions Nov 18, 2023 pm 03:26 PM

Complete list of PHP file download functions: File download example analysis of readfile, header, Content-Disposition and other functions. File download is one of the essential functions in Web applications, and PHP, as a widely used Web development language, provides many A function and method to implement file downloading. This article will introduce commonly used file download functions in PHP, including readfile, header, Content-Dispo

See all articles