我有一个发送按钮,其ID是'btnEmail'。我的代码只发送邮件到指定的电子邮件。我想发送给多人而不共享电子邮件ID。我的代码在这里:
<?php
if(isset($_POST['btnEmail']))
{
require_once("../include/phpmailer/class.phpmailer.php");
$mail1 = new PHPMailer(); // create a new object
$mail1->IsSMTP(); // enable SMTP
$mail1->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail1->SMTPAuth = true; // authentication enabled
$mail1->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail1->Host = "smtp.gmail.com";
$mail1->Port = 465; // or 587
$mail1->IsHTML(true);
$mail1->Username = "some_mail@gmail.com"; // SMTP username
$mail1->Password = "Sup3rS3cr3T"; // SMTP password
$mail1->SetFrom("some_mail@gmail.com");
$mail1->Subject = "Testing mail for php";
$mail1->Body = "<html><h4>Tested Successfully</h4></html>";
$mail1->AddAddress('another_mail@gmail.com');
}
答案 0 :(得分:0)
您似乎正在使用phpmailer。你检查了它给出的例子吗?
https://github.com/Synchro/PHPMailer/blob/master/examples/mailing_list.phps
这应存在于您的计算机或服务器上。您也可以阅读文档,这很有帮助。