Problems when using SMTP to send emails

Source: Internet
Author: User
Tags mail php example string format
Below is a php example program (adapted) that uses smtp to send emails directly, but the server always prompts: 550 system busy! The email cannot be sent.
Who knows how to deal with it?
What should I do if the smtp server requires a password?
Sory, I just saw the smtp mail sending problem (why isn't this post linked to the essence ?, We recommend that you give it one ).
The problem has been solved:
1. The data command should be "DATA"
2. The from and to commands should be available; otherwise, some servers reject emails.
3. Use base64_encode to encrypt the user name and password
<? Php
Require ("phpmail. php ");
?>
<?
$ Smtp = "smtp.163.net ";
$ From = "hylpro@163.net ";
$ To = "hylpro@163.net ";
$ Subject = "Hello php mail ";
$ Message = "Hello! This is a test use php ";
$ Mail = new mail ($ smtp, "Welcom use this mail", true );
$ Mail-> send ($ to, $ from, $ subject, $ message );
?>

<?
//---------------
// Implement SMTP
//---------------
Class Mail {
Var $ lastmessage; // record the last response
Var $ lastact; // The final action, in the string format
Var $ welcome; // used after HELO. welcome
Var $ debug; // whether to display debugging information
Var $ smtp; // smtp server
Var $ port; // smtp port number
Var $ fp; // socket handle
// Construct
Function mail ($ smtp, $ welcome = "", $ debug = false)
{
If (empty ($ smtp) die ("SMTP cannt be NULL! ");
$ This-> smtp = $ smtp;
If (empty ($ welcome ))
{
$ This-> welcome = gethostbyaddr ("localhost ");
}
Else
$ This-> welcome = $ welcome;
$ This-> debug = $ debug;
$ This-> lastmessage = "";
$ This-> lastact = "";
$ This-> port = "25 ";
}
//
Function show_debug ($ message, $ inout)
{
If ($ this-> debug)
{
If ($ inout = "in") // response information
{
$ M = "<B> accept: </B> ";
}
Else
$ M = "<B> hair: </B> ";
If (! Ereg ("n $", $ message ))
$ Message. = "";

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.