Allows the Hostmonster website program to send emails as well.

Source: Internet
Author: User
Tags cpanel email account

Generally, the HostMonster website program cannot send emails because port 25 is blocked.

Many ISPs shield port 25, which is used to send emails. They do this to reduce the amount of Spam Sent. All e-mails sent over the Internet must use port 25, which is used for communication between the e-mail client and the e-mail server.

Although port 25 shielding is likely to become an industrial standard, filters may cause troubles to the e-mail server, resulting in normal mail being treated as spam.

Port 25 blocking can help network service providers prevent the spread of junk information on their networks. However, it will cause trouble for those who need to use the e-mail server. These servers are not just provided by their own ISP.

Network service providers that shield port 25 require that their SMTP servers be used instead of remote SMTP servers or SMTP servers running on their computers.

Fortunately, HostMonster opened port 26 to the SMTP server.

Go to CPanel-> Email Accounts to create an Email account.

Then go to CPanel-> webmail-> Configure Mail Client to 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) 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)

Tip: smtp server is mail.yourdomain.com, port is 26, account is the complete address of your mailbox xxxx@xxx.com, password is your mailbox password. Follow the prompts to set up the SMTP service provided by the hostmonster host.

The example program is as follows. The program uses the PHPmailer Library:

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">  </div>'; $ body. = '<p> '. $ nickname. ', hello. </P> '; $ body. = 'click the following link to verify your email address. Note that the domain name is bkjia.com: <a href = "'. base_url (). 'accounts/activation/"target =" _ blank "> '. base_url (). 'accounts/activation/</a> '; $ body. = '<p> I wish you a pleasant job and a pleasant life. </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 = "receive an email from the customer's house"; $ 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 can send emails. However, not all emails can be received. If you test this function, 163 and gmail can be normally received, but qq cannot. If you have a better method, please let me know and thank you.

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.