I know that in first look many users mark this question as duplicate, but after reading more than 10 question I did not get any satisfactory answer, almost all question has answers having words like "There's not much you can do about it.", "I am not sure", "There is no sure shot trick" etc. that's why I am writing this question, and I think this is very generalized questions and every php developer faces it at least once, ok enough speech :) , now my question is..
I working on a project management application and am using phpmailer to send mail when any task is created or anybody comments on any bug mails are sent to related users, actually instead of sending mails as soon the action happens I have created a 'notifications' table where I actually save all mail data and a cron script then send all mails, here is some part of my cron script.
$query = "select * from notifications where 1 ";
$projects = $obj_basic->get_query_data($query);
if(!empty($projects))
{
foreach($projects as $data)
{
$message = html_entity_decode($data['content'], ENT_QUOTES);
list($ton, $email) = get_name_email($data['to']);
if(!empty($email))
{
$query = "select send_notification from users where email='$email' AND send_notification !='1' ";
$users = $obj_basic->get_query_data($query);
if(!empty($users))
{
$deleteQuery = "delete from notifications where id ='".$data['id']."'";
$obj_basic->run_query($deleteQuery, 'DELETE');
continue;
}
$comment_id = $data['reference_id'];
$attribute = $data['attribute'];
$mail = new PHPMailer();
list($fromName, $fromEmail) = get_name_email($data['from']);
if(!empty($comment_id) && $attribute == 'comment')
{
$fromEmail = 'comment@changewebaddress.com';
}
$mail->SetFrom($fromEmail, $fromName);
$mail->AddReplyTo($fromEmail, $fromName);
$mail->AddAddress($email, $ton);
$mail->BouncedTo = $fromEmail;
$mail->IsHTML(true);
$mail->Subject = $data['subject'];
$mail->Body = $message;
$MessageID = "<".md5($comment_id.'_'.$email).'@changewebaddress.com>';
$mail->MessageID= $MessageID;
if($mail->Send()) {
if(!empty($comment_id) && $attribute == 'comment')
{
$query = "SELECT message_id FROM `project_comments` WHERE `id`='$comment_id'; ";
$project_comments = $obj_basic->get_query_data($query, 'SELECT');
if(!empty($project_comments))
{
$project_comments[0]['message_id'] = html_entity_decode(trim($project_comments[0]['message_id'], ","));
$query = "UPDATE `project_comments` SET `message_id`=CONCAT_WS(',', '".mysql_escape_string($project_comments[0]['message_id'])."', '".mysql_escape_string(html_entity_decode($MessageID))."') WHERE `id`='$comment_id'; ";
$obj_basic->run_query($query, 'UPDATE');
}
}
$deleteQuery = "delete from notifications where id ='".$data['id']."'";
$obj_basic->run_query($deleteQuery, 'DELETE');
}
}
}
}
as per what I have tested everything look good, since I am using phpmailer it sets required header it also sets 'Return-Path:' and 'Reply-To:' in header.
Is there any exact solution on this issue
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…