让Hostmonster的网站程序也能发送邮件
HostMonster网站程序一般无法发送邮件,因为端口25阻塞了。
许多ISP屏蔽了端口25的使用,而该端口是用来发送邮件的。他们这样做是为了减少垃圾邮件的发送量。所有通过Internet发送的 e-mail 都要通过端口25, 该通道用来进行e-mail 客户端和 e-mail服务器之间的通信。
虽然端口25屏蔽很可能成为一个工业标准,但是过滤器会给 e-mail服务器带来麻烦,导致正常的邮件被当成垃圾邮件处理。
端口25屏蔽可以帮助网络服务供应商们阻止垃圾信息在他们的网络上的传播,但是这样的话,会给那些有需求使用e-mail服务器发送邮件的人带来麻烦,这些服务器不仅仅是他们自己的ISP提供的。
屏蔽端口25的网络服务供应商要求使用他们的SMTP服务器,而不是远程SMTP服务器或自己电脑上运行的SMTP服务器。
还好的是,HostMonster开放了26端口给SMTP服务器。
我们先到 CPanel -> Email Accounts,创建一个邮件账户。
然后到 CPanel -> webmail -> Configure Mail Client,可以得到下面配置信息:
Manual Settings Mail Server Username: bkjia+bkjia.com Incoming Mail Server: mail.bkjia.com Incoming Mail Server: (SSL) host.hostmonster.com Outgoing Mail Server: mail.bkjia.com (server requires authentication) port 26 Outgoing Mail Server: (SSL) host.hostmonster.com (server requires authentication) port 465 Supported Incoming Mail Protocols: POP3, POP3S (SSL/TLS), IMAP, IMAPS (SSL/TLS) Supported Outgoing Mail Protocols: SMTP, SMTPS (SSL/TLS)
提示:smtp服务器是 mail.yourdomain.com,端口是26,帐号是你的邮箱的完整地址 xxxx@xxx.com,密码就是你的邮箱密码。按照提示设置好,就可以使用hostmonster主机提供的SMTP服务了。
示例程序如下,程序使用了PHPmailer库:
function mailto($nickname, $address) { $this->load->helper('url'); date_default_timezone_set('PRC'); include_once("application/controllers/class.phpmailer.php"); $mail = new PHPMailer(); // defaults to using php "mail()" $mail->IsSMTP(); // telling the class to use SMTP $mail->IsHTML(true); $mail->Host = "mail.bkjia.com"; // SMTP server $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "mail.bkjia.com"; // sets the SMTP server $mail->Port = 26; // set the SMTP port for the GMAIL server $mail->Username = "bkjia@bkjia.com"; // SMTP account username $mail->Password = "********"; // SMTP account password $mail->CharSet="utf-8"; //$body = file_get_contents('application/views/nmra/register.html'); //$body = preg_replace('/\\\\/','', $body); //Strip backslashes $body = '<body style="margin: 10px;">'; $body .= '<div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 14px; ">'; //$body .= '<div align="center"><img src="/static/imghw/default1.png" data-src="images/phpmailer.gif" class="lazy" style="max-width:90%" alt="让Hostmonster的网站程序也能发送邮件" ></div>'; $body .= '<p>'.$nickname.',您好。</p>'; $body .= '请点击以下链接验证您的邮箱,请注意域名为bkjia.com:<a href="'.base_url().'accounts/activation/" target="_blank">'.base_url().'accounts/activation/</a>'; $body .= '<p>顺祝工作学习愉快,生活舒心。</p>'; $body .= '</div></body>'; //echo $body; $mail->AddReplyTo("bkjia@163.com","Gonn"); $mail->SetFrom('bkjia@163.com', 'Gonn'); $mail->AddReplyTo("bkjia@163.com","Gonn"); $mail->AddAddress($address, $nickname); $subject = "收到来自帮客之家的邮件"; $mail->Subject = "=?UTF-8?B?".base64_encode($subject)."?="; // optional, comment out and test $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; $mail->MsgHTML($body); //$mail->AddAttachment("images/phpmailer.gif"); // attachment //$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment if(!$mail->Send()) { //echo "Mailer Error: " . $mail->ErrorInfo; } else { //echo "Message sent!"; } }
OK,现在网站程序就能发邮件了。但是并非所有邮箱都能收到,这里测试的话,163,gmail等都能正常收到,而qq则收不到。如果你有更好的方法,请告知我,感谢。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Is the Outlook mail icon missing from Windows 11's Control Panel? This unexpected situation has caused confusion and concern among some individuals who rely on OutlookMail for their communication needs. Why don't my Outlook emails show up in Control Panel? There may be several possible reasons why there are no Outlook mail icons in Control Panel: Outlook is not installed correctly. Installing Office applications from the Microsoft Store does not add the Mail applet to Control Panel. The location of the mlcfg32.cpl file in Control Panel is missing. The path to the mlcfg32.cpl file in the registry is incorrect. The operating system is not currently configured to run this application

If you find that blank pages appear when printing a mail merge document using Word, this article will help you. Mail merge is a convenient feature that allows you to easily create personalized documents and send them to multiple recipients. In Microsoft Word, the mail merge feature is highly regarded because it helps users save time manually copying the same content for each recipient. In order to print the mail merge document, you can go to the Mailings tab. But some Word users have reported that when trying to print a mail merge document, the printer prints a blank page or doesn't print at all. This may be due to incorrect formatting or printer settings. Try checking the document and printer settings and make sure to preview the document before printing to ensure the content is correct. if

We've been talking lately about the many features Microsoft plans to add to its latest operating system, Windows 11. But don't think that Microsoft will add nothing and take nothing back. In fact, the software giant started removing quite a few old features. After announcing plans to decommission MSDT functionality ahead of the release of Windows 12, a Redmond developer has more bad news. We are actually talking about remote mail slot legacy tool. Trust us when we say you actually want to know this. Microsoft has started deprecating this feature in build 25314. We are sure you remember that just a few days ago, Microsoft released build 25314 in its new canary channel. The above version contains many new features

PHP sends emails asynchronously: avoid long waits for emails to be sent. Introduction: In web development, sending emails is one of the common functions. However, since sending emails requires communication with the server, it often causes users to wait for a long time while waiting for the email to be sent. In order to solve this problem, we can use PHP to send emails asynchronously to optimize the user experience. This article will introduce how to implement PHP to send emails asynchronously through specific code examples and avoid long waits. 1. Understanding sending emails asynchronously

Recently, many users have reported the issue of Outlook emails getting stuck in the outbox. Even after several attempts to send the email, the issue was not resolved. When you see this issue and check your outbox folder, the message will be stuck there. Possible reasons for emails getting stuck in Outlook outbox: The attachments in the email exceed the size limit, which slows down the sending process. Outlook account authentication issues with mail server Incorrect send/receive settings in Outlook or mail server offline Outlook. Outlook data files are being used by some other software. Antivirus software scans outgoing emails. If this problem has been bothering you and you are unable to send an email

PHP email tracking function: understand user behavior and feedback on emails In modern society, email has become an indispensable part of people's daily life and work. For businesses, sending emails is one of the important ways to communicate with customers and promote products or services. However, after an email is sent, how do we know whether it was received, read, or how the user reacted to the content of the email? At this time, the email tracking function becomes particularly important. The email tracking function can help us understand user behavior and feedback on emails

Have you noticed that when you try to delete a message in Gmail on iOS, you only see the archive option? Read on to learn how to delete Gmail on iPhone without archiving it in the Mail app. The setting to change the default option for archiving Gmail emails using the Mail app on iPhone and iPad is completely hidden in Settings, but it can be changed quickly once you know where to go. Keep in mind that this tutorial is for people using Gmail through the Apple Mail app on iPhone and iPad. Another option is to use the Gmail app on your iPhone/iPad. you even

As part of updating native apps for Windows 11, Microsoft plans to release a new Outlook. The app was built from the ground up and is now being prepared for preview, which will likely be announced during Microsoft's Windows 11 hybrid event. The project is called "ProjectMonarch" and this new Outlook has been in development for over a year. This is a reboot of the web app that aims to unify all existing Windows email clients such as Mail and Calendar as well as the desktop version of Outlook. With OutlookOne, Microsoft hopes to help users manage their email across different desktop platforms. There are many ways to access
