Ecshop implements smtp directmail _ PHP Tutorial

Source: Internet
Author: User
Ecshop implements smtp mail sending. Ecshop implements smtp mail sending this article mainly introduces how ecshop implements smtp mail sending. if you need it, you can refer to the ECShop smtp method to send mail, in the cls_smtp file, ecshop implements smtp mail sending.

This article mainly introduces how to use ecshop to send emails through smtp. For more information, see

When sending an email using ECShop smtp, execute the following statement in the get_data method in the cls_smtp class file:

The code is as follows:

$ Line = fgets ($ this-> connection, 512 );

;, Timeout error occurs.

Comment out the execution of this function and send an email directly. the error ehlo command failed is returned.

However, when the link data is printed, it is connected.

Previously, emails can be sent normally by using other programs. Therefore, the resend function uses phpmailer to send emails.

The code is as follows:

Function smtp_mail ($ name, $ email, $ subject, $ content, $ type = 1, $ notification = false ){

/* If the email encoding is not EC_CHARSET, create a character set conversion object and convert the encoding */

If ($ GLOBALS ['_ CFG'] ['mail _ charset']! = EC_CHARSET)

{

$ Name = ecs_iconv (EC_CHARSET, $ GLOBALS ['_ CFG'] ['mail _ charset'], $ name );

$ Subject = ecs_iconv (EC_CHARSET, $ GLOBALS ['_ CFG'] ['mail _ charset'], $ subject );

$ Content = ecs_iconv (EC_CHARSET, $ GLOBALS ['_ CFG'] ['mail _ charset'], $ content );

$ Shop_name = ecs_iconv (EC_CHARSET, $ GLOBALS ['_ CFG'] ['mail _ charset'], $ GLOBALS ['_ CFG'] ['shop _ name']);

}

$ Charset = $ GLOBALS ['_ CFG'] ['mail _ charset'];

Include_once ROOT_PATH. 'includes/phpmailer/class. phpmailer. php ';

$ Mail = new PHPMailer ();

$ Mail-> From = $ GLOBALS ['_ CFG'] ['smtp _ user'];

$ Mail-> FromName = 'Yunnan *** Broadcasting Co., Ltd ';

If ($ GLOBALS ['_ CFG'] ['mail _ service'] = 0 ){

$ Mail-> isMail ();

} Else {

$ Mail-> IsSMTP ();

$ Mail-> Host = $ GLOBALS ['_ CFG'] ['smtp _ host'];

$ Mail-> Port = $ GLOBALS ['_ CFG'] ['smtp _ port'];

$ Mail-> SMTPAuth =! Empty ($ GLOBALS ['_ CFG'] ['smtp _ pass']);

$ Mail-> Username = $ GLOBALS ['_ CFG'] ['smtp _ user'];

$ Mail-> Password = $ GLOBALS ['_ CFG'] ['smtp _ pass'];

}

$ Mail-> Encoding = "base64 ";

// $ Mail-> Priority = $ this-> priority;

$ Mail-> CharSet = $ charset;

$ Mail-> IsHTML ($ type );

$ Mail-> Subject = $ subject;

$ Mail-> Body = $ content;

$ Mail-> Timeout = 30;

$ Mail-> SMTPDebug = false;

$ Mail-> ClearAddresses ();

$ Mail-> AddAddress ($ email, $ name );

$ Mail-> ConfirmReadingTo = $ notification;

$ Res = $ mail-> Send ();

If (! $ Res)

{

$ GLOBALS ['err']-> add ($ mail-> ErrorInfo );

$ GLOBALS ['err']-> add ($ GLOBALS ['_ LANG'] ['sendemail _ false']);

Return false;

}

Return true;

}

The above is all the content of this article. I hope my friends will like it.

This article mainly introduces how to use ecshop to send mails through smtp. if you need it, refer to the cls_smtp file when sending mails using the smtp method of ECShop...

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.