我试图通过邀请填写表单向所有客户发送电子邮件。该电子邮件包含该网站的登录信息,因此对于每个客户而言,它是不同的邮件。我总共有600多个客户,但我试图发送100个组。但是,它只发送给前24-25个收件人。 我是新来的,你能帮帮我吗?
这是我的代码:
选择前100位客户的所有电子邮件地址的表单,并在我点击发送时向每位客户发送自定义消息:
<?php
include ('header.php');
$con = mysqli_connect("localhost", "root", "", "export_declarations");
$result = mysqli_query($con,"SELECT c_id, company_name,username,password,name, email, authorized_person_name,authorized_person_email FROM test_invite
WHERE c_id<75 AND (grouping ='' OR grouping LIKE '%no agreement%' OR grouping LIKE '%merger with client%')");
while ($row = mysqli_fetch_assoc($result))
{
$data[$row['c_id']]['ID'] = $row['c_id'];
$data[$row['c_id']]['comp_name'] = $row['company_name'];
$data[$row['c_id']]['contacts'] = $row['name'];
$data[$row['c_id']]['contacts_emails'] = str_replace(",",", ",$row['email']);
$data[$row['c_id']]['authorized_contact_name'] = $row['authorized_person_name'];
$data[$row['c_id']]['authorized_contact_email'] = $row['authorized_person_email'];
$data[$row['c_id']]['username'] = $row['username'];
$data[$row['c_id']]['password'] = $row['password'];
}
$html = "<table>
<form method = 'post'>
<th><u>A.</u> <br/>Company ID</th>
<th><u>B.</u> <br/> Company name</th>
<th><u>C.</u> <br/> All contacts</th>
<th><u>D.</u> <br/> E-mails, all contacts</th>
<th><u>E.</u> <br/> Authorized contact</th>
<th><u>F.</u> <br/> E-mail, authorized contact</th>";
foreach ($data as $key=>$val)
{
$html .= "<tr>
<input type = 'hidden' name = 'name[{$key}]' value = '{$data[$key]['authorized_contact_name']}'>
<input type = 'hidden' name = 'email[{$key}]' value = '{$data[$key]['authorized_contact_email']}'>
<input type = 'hidden' name = 'username[{$key}]' value = '{$data[$key]['username']}'>
<input type = 'hidden' name = 'pass[{$key}]' value = '{$data[$key]['password']}'>
<input type = 'hidden' name = 'company[{$key}]' value = '{$data[$key]['comp_name']}'>";
foreach ($val as $subkey => $value)
{
if (!(($subkey == 'username') OR ($subkey == 'password')))
{
$html .="<td>{$value}</td>";
}
}
$html .="</tr>";
}
$html .="</table>
<input type='submit' name='doSubmit' value = 'send'>
</form>";
echo $html;
if (isset($_POST['doSubmit']))
{
include('send_mail_logins.php');
}
send_mail_logins.php
<?php
require '/../PHPMailer/PHPMailerAutoload.php';
foreach ($_POST['name'] as $key=>$val)
{
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Username = "camelia.petriu@gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->From = 'camelia.petriu@gmail.com';
$mail->FromName = 'camelia.petriu@com';
$mail->WordWrap = 50;
$mail->isHTML(true);
$mail->Subject = 'Request for Export Details';
$mail->addAddress("{$_POST['email'][$key]}");
$content ="<p>Dear {$val},</p>
<p>...</p>
Username: {$_POST['username'][$key]}
Password: {$_POST['pass'][$key]}";
$sent_to = "";
$not_sent_to="";
$mail->Body = $content;
//$mail->AltBody = $altcontent;
if(!$mail->send()) {
$not_sent_to .= "<p style = 'color:red'>Message could not be sent to {$_POST['email'][$key]}.</p>";
echo 'Mailer Error: ' . $mail->ErrorInfo;}
}
else
{
$sent_to.= "<p>Message sent to {$_POST['email'][$key]}</p>";
}
}
echo $sent_to;
echo $not_sent_to;
我稍后会将我的gmail帐户替换为我们的组织帐户
非常感谢!
答案 0 :(得分:0)
您不应该使用GMail发送批量电子邮件,而且我会说您遇到了错误,因为您已经达到GMail发送限制。要小心,因为这样做经常会阻止你的GMail帐户! (见http://www.labnol.org/internet/email/gmail-daily-limit-sending-bulk-email/2191/)
我建议您考虑注册正确的交易电子邮件服务,例如Mandrill。即使他们的免费套餐也允许您每月发送大约10,000封电子邮件。