我需要知道使用 php 发送多封电子邮件的最佳方法是什么。它不应该存储在垃圾邮件中,也应该快速发送。
我已经在 PHP 中尝试过普通的邮件功能。但它运作不佳。还尝试在循环中使用邮件功能。只发送了几封邮件,其中一些邮件到达了垃圾邮件文件夹。
我的项目正在实时服务器上运行。我正在使用免费托管服务。
我的代码:
<?php
include "initialize.php";
if($source_url!='http://kalaivanan.byethost18.com/uadmin/send_result.php')
{
echo "Access Denied";
}
else
{
$id=$_GET['id'];
$get_sem_period1=mysqli_query($con, "SELECT * FROM sem_period where id='$id' ");
$get_sem_period=mysqli_fetch_array($get_sem_period1);
$sem_period=$get_sem_period['sem_period'];
$rrr=mysqli_query($con, "SELECT * FROM results where sem_period='$sem_period' ");
$i=1;
while($row=mysqli_fetch_array($rrr))
{
$get_course=mysqli_query($con, "SELECT course,email FROM student_details where reg_no='$row[reg_no]' ");
$get_course1=mysqli_fetch_array($get_course);
$course_name=$get_course1['course'];
$to=$get_course1['email'];
$get_sub1=mysqli_query($con, "SELECT * from course_details where course_name='$course_name' ");
$get_sub=mysqli_fetch_array($get_sub1);
$sem_no=$row['sem_no'];
$subjects=$get_sub['sem'.$sem_no];
$new_subjects=explode(",",$subjects);
$new_marks=explode(",", $row['sem_mark']);
$echo_subject=null;
for($x=0;$x<sizeof($new_subjects);$x++)
{
if($new_marks[$x]>40)
{
$exam_result="Pass";
}
else
{
$exam_result="Fail";
}
$echo_subject .="<tr><td>".$new_subjects[$x].": ".$new_marks[$x]." - ".$exam_result."</td></tr>";
}
$errors='';
$myemail = 'MYEMAIL';
if( empty($errors))
{
$email_subject = "Enquiry Form: Your Results";
echo "Mail id is: ".$to;
echo $email_body = "<table border='1'>
</br> $sem_period Result Will be Announced: Check Your Marks </br> </br>
<tr>
<td> Register Number: ".$row['reg_no']. "</td>
</tr>
<tr>
<td> Course Name: ".$course_name. "</td>
</tr>
<tr>
<td> Semester: ".$sem_no. "</td>
</tr>
<tr>
<td>MARKS ARE:</td>
</tr>
<tr>
<td> ".$echo_subject." </td>
<td> </td>
</tr>
</table>
";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $myemail";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
echo "<script>alert('Mail Send Successfully');</script>";
}
$email_address="MYEMAIL";
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
}
}
?>
我的答案:
一年后,根据我的经验,我了解到要发送没有垃圾邮件的大邮件,我们必须找到好的邮件服务提供商。