PHPmailer发送邮件

1670108266a3184e255f1f2ebe78ae4034fa9d94.jpg

phpmailer发送邮件,可以循环批量发送

CharSet = 'UTF-8';
            $mail->SMTPDebug = 2;                                       // Enable verbose debug output
            $mail->isSMTP();                                            // Set mailer to use SMTP
            $mail->Host = 'smtp.qq.com';                                // Specify main and backup SMTP servers
            $mail->SMTPAuth = true;                                     // Enable SMTP authentication
            $mail->Username = '[email protected]';                            // SMTP username
            $mail->Password = '2323232';                                // SMTP password
            $mail->SMTPSecure = 'ssl';                                  // Enable TLS encryption, `ssl` also accepted
            $mail->Port = 465;                                          // TCP port to connect to

            //Recipients
            $mail->setFrom('[email protected]', 'test');
//            $mail->addAddress('[email protected]', 'Joe User');     // Add a recipient
            $mail->addAddress($getMsg);               // Name is optional
//            $mail->addReplyTo('[email protected]', 'Information');
//            $mail->addCC('[email protected]');
//            $mail->addBCC('[email protected]');

            // Attachments
//            $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
//            $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

            // Content
            $mail->isHTML(true);                                  // Set email format to HTML
            $mail->Subject = 'Here is the subject';
            $mail->Body = <<in bold!
html;
            $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

            $mail->send();
            echo 'Message has been sent';
            exit;
        } catch (Exception $e) {
            echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
            exit;
        }
    }

你可能感兴趣的:(PHPmailer发送邮件)