PHP Send mail ____php

Source: Internet
Author: User
Tags php send mail email account server port

Recently there is nothing to write a PHP Web page program to send files, several failed to finally succeed, encountered a lot of pits, the online comparison of the simple, involved in many of the points are not mentioned, here to share their experience, I hope to help you readers.
There are two ways to send mail in PHP: 1. Use PHP with Functions Mail (), 2.php send the socket to send e-mail. I'm using the first way, through the mail function, you can download the email.class.php file containing this function online. I use the SMTP server is 163 mailbox, direct point, on the code, if you have the code has been failed and can not find the reason, please read carefully the analysis behind.
Index.html '

<form action= "sendmail.php" method= "POST" >
    <p> Recipient <input type= "text" name= "Toemail"/></p >
    <p> title <input type= "text" name= "title"/></p>
    <p> content <textarea name= "content" cols= "rows=" "5" ></textarea></p>
    <p><input type= "Submit" value= "send"  /></p >
</form>

sendmail.php

<?php require_once "email.class.php"; Configuration information ******************************** $smtpserver = "smtp.163.com";//SMTP server $smtpserverpor T =25;//SMTP server Port $smtpusermail = "Your 163 mailbox";//your registered email account $smtpemailto = $_post[' toemail '];//sent to whom $smtpuser = "your 163 Mailbox "//with the above registered mailbox account $smtppass =" Authorization code (different from account password) ";//smtp Server user Password $mailtitle = $_post[' title '];//Mail subject $mailconten t = " 

       sendmail.php Configuration We can find that an existing mailbox is needed. Obviously, the workflow of sending mail in this way is probably: the PHP program simulates the user's mailbox that is logged in to send the message to the recipient. I tested the time send failed, given the error remote host returned "has no permission". We analyze the cause of the error: we log in when the mailbox is to use a specific landing entrance, such as QQ Landing mailbox has QQ mailbox page, APP, under normal circumstances in the third party landing mailbox is not allowed. Use the PHP program to send mail, where the PHP program is a third party, then how to solve this problem.
        mailboxes have a smpt setting, and SMTP (Simple Mail Transfer Protocol) is simply a mail Transfer protocol. It is a set of rules for sending messages from the source address to the destination, and it controls how the letters are relayed. The SMTP protocol belongs to the TCP/IP protocol cluster, which helps each computer find the next destination when sending or relaying letters. The server specified by the SMTP protocol, you can send e-mail to the recipient's server, the whole process only a few minutes. The SMTP server is the outgoing mail server that follows the SMTP protocol and is used to send or relay outgoing e-mail messages.
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP If we need to open the SMTP service when the third party logs in, we will refuse to log in. Prompts you to set the mailbox's authorization code when it is turned on, which is the password that we use to configure the mail function parameters. In addition, you can open the SMTP service QQ, so you do not need to download QQ mailbox app can be used directly from the mobile phone with the Mail app to login QQ mailbox. Failure at this point is caused by the server's refusal to log in and send mail using the Mail function to ensure that the mailbox you provide opens the SMTP service. If you are prompted to send a message successfully without receiving the message, you may have been placed in the trash. Another way of sending mail will also continue to study, welcome to study together.

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.