The call process of using the mail sending interface in the php programming language

  For the process of how to use the smtp class to send emails, many technical beginners do not quite understand, and usually encounter many problems in the programming process, and some do not even know the calling process of the interface, so in this case, The following will explain to you the process of how to use the mail sending interface call in the php programming language. The implementation code and comments are as follows:

    1. Open php.ini, find extension=php_openssl.dll, remove the previous semicolon, and restart the server. If this configuration is already turned on, skip this step.

    2. Send mail code

      $MailServer = "smtp.163.com"; //SMTP server (if not 163 mailbox is configured as the corresponding smtp server)

      $MailPort = 25; //SMTP server port

      $smtpMail = "[email protected]"; //User mailbox of SMTP server

      $smtpuser = "xxxxx"; //User account of SMTP server (excluding email suffixes such as @163.com)

      $smtppass = "Email password or authorization code"; //User password or authorization code of the SMTP server (sometimes it can also be set to the mailbox password, if not, it is set to the authorization code)

      $email = trim($email);//Email address to send

      //Associate the smtp class and create a $smtp object, one of which is true means that authentication is used, otherwise authentication is not used.

      require_once './Index/Modules/Home/Action/smtp.class.php';

      $smtp = new Smtp($MailServer, $MailPort, $smtpuser, $smtppass, true);

      $smtp->debug = false;//Write true in the debugging phase to see the error message, and set it to false in the deployment phase

      $mailType = "HTML"; //mail type, text: text; web page: HTML

      $email = $email; //Recipient mailbox

      $emailTitle = ""; //email subject

      $emailTitle = "=?UTF-8?B?".base64_encode($emailTitle)."?=";//Sometimes the subject of the email will appear garbled, at this time add this line of code

      $emailBody = "";//email content

      $smtp->sendmail($email,$smtpMail,$emailTitle,$emailBody,$mailType);

  The above is the invocation process of sending the interface by mail for you. Technical personnel who understand it can try it out. If you have any questions, you can leave a message below to consult us.

  This article is organized and published by Yixuan Technology, a professional app development company. It is original content. If interested technical personnel want to reprint, please indicate the author and source!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324521337&siteId=291194637