您好,欢迎访问一九零五行业门户网

让Hostmonster的网站程序也能发送邮件_PHP教程

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 settingsmail server username: bkjia+bkjia.comincoming mail server: mail.bkjia.comincoming mail server: (ssl) host.hostmonster.comoutgoing mail server: mail.bkjia.com (server requires authentication) port 26outgoing mail server: (ssl) host.hostmonster.com (server requires authentication) port 465supported 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 .= ''; //$body .= '
'; $body .= ''.$nickname.',您好。
'; $body .= '请点击以下链接验证您的邮箱,请注意域名为bkjia.com:'.base_url().'accounts/activation/'; $body .= '顺祝工作学习愉快,生活舒心。
'; $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则收不到。如果你有更好的方法,请告知我,感谢。
http://www.bkjia.com/phpjc/752343.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/752343.htmltecharticlehostmonster网站程序一般无法发送邮件,因为端口25阻塞了。 许多isp屏蔽了端口25的使用,而该端口是用来发送邮件的。他们这样做是为了减少...
其它类似信息

推荐信息