Let Hostmonster's website program also send mail _php tutorials

Source: Internet
Author: User
Tags cpanel mail account
Hostmonster Web site programs generally cannot send mail because port 25 is blocked.

Many ISPs block the use of port 25, which is used to send mail. They do this to reduce the amount of junk e-mail sent. All e-mails sent over the Internet are routed through port 25, which is used for communication between the e-mail client and the e-mail server.

Although the port 25 shield is likely to become an industry standard, the filter will cause trouble to the e-mail server, resulting in normal mail being treated as spam.

Port 25 masking helps network service providers prevent the spread of spam on their networks, but in this case, it can cause problems for those who need to use e-mail servers to send e-mails, which are not just provided by their own ISPs.

Network Service providers that block port 25 require that their SMTP server be used instead of the remote SMTP server or the SMTP server running on their own computer.

Fortunately, Hostmonster opened 26 ports to the SMTP server.

We'll go to CPanel-e email Accounts to create a mail account.

Then to Configure Mail Client, CPanel-Webmail, you can get the following configuration information:

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) Ho St.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)

Tip: The SMTP server is mail.yourdomain.com, the port is 26, the account is the full address of your mailbox xxxx@xxx.com, password is your mailbox password. With the prompts set, you can use the SMTP service provided by the Hostmonster host.

The sample program is as follows and the program uses the Phpmailer library:

function mailto ($nickname, $address) {$this->load->helper (' url ');d ate_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. ', hello.

'; $body. = ' Please click on the link below to verify your email address, please note that the domain name is bkjia.com: '. Base_url (). ' Accounts/activation/'; $body. = '

I wish you a pleasant work and a comfortable life.

'; $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 received from a customer's home"; $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"); Attachmentif (! $mail->send ()) {//echo "Mailer Error:". $mail->errorinfo;} else {//echo "Message sent!";}}

OK, now the website program will be able to send e-mail. But not all mailbox can receive, here test, 163,gmail and so can receive normally, and QQ is not received. If you have a better way, please let me know, thank you.

http://www.bkjia.com/PHPjc/752343.html www.bkjia.com true http://www.bkjia.com/PHPjc/752343.html techarticle hostmonster Web site programs generally cannot send mail because port 25 is blocked. Many ISPs block the use of port 25, which is used to send mail. They are doing this to reduce ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.