6

is anybody know any solution for below problem

in my project, i am send email to client using smtp and php mailer and gmail script. so when i am send mail gmail send mail to particular client. for that i am passing gmail login and user name which is valid. all mail are sending properly. but sometime it may happen that some client not receive mail and at that time i am not able to get or trace any error. so i there any way, when i am sending mail to client , and when client get it and read it at that time i got any kind of confirmation.

Please if anybody have any idea , help me out.

Jigar Oza
  • 115
  • 1
  • 1
  • 8
  • Without making this too complicated you could sign up for a service like mailgun and then the tracking or received, opened or bounced is nicely managed. – Barry Apr 04 '16 at 07:28

3 Answers3

1
<?php
/**
* Simple example script using PHPMailer with exceptions enabled
* @package phpmailer
* @version $Id$
*/

require ('../class.phpmailer.php');

try {
        $mail = new PHPMailer(true); //New instance, with exceptions enabled

        $body             = "Please return read receipt to me.";
        $body             = preg_replace('/\\\\/','', $body); //Strip backslashes

        $mail->IsSMTP();                           // tell the class to use SMTP
        $mail->SMTPAuth   = true;                  // enable SMTP authentication
        $mail->Port       = 25;                    // set the SMTP server port
        $mail->Host       = "SMTP SERVER IP/DOMAIN"; // SMTP server
        $mail->Username   = "EMAIL USER ACCOUNT";     // SMTP server username
        $mail->Password   = "EMAIL USER PASSWORD";            // SMTP server password

        $mail->IsSendmail();  // tell the class to use Sendmail

        $mail->AddReplyTo("someone@something.com","SOMEONE");

        $mail->From       = "someone@something.com";
        $mail->FromName   = "SOMEONE";

        $to = "other@something.com";

        $mail->AddAddress($to);

        $mail->Subject  = "First PHPMailer Message[Test Read Receipt]";

        $mail->ConfirmReadingTo = "someone@something.com"; //this is the command to request for read receipt. The read receipt email will send to the email address.

        $mail->AltBody    = "Please return read receipt to me."; // optional, comment out and test
        $mail->WordWrap   = 80; // set word wrap

        $mail->MsgHTML($body);

        $mail->IsHTML(true); // send as HTML

        $mail->Send();
        echo 'Message has been sent.';
} catch (phpmailerException $e) {
        echo $e->errorMessage();
}
?>

Some modification need to be done in above script.

  1. Configure SMTP mail server.

  2. Set the correct FROM & FROM Name (someone@something.com, SOMEONE)

  3. Set the correct TO address

from

also

  1. Delivery reports and read receipts in PHP mail
Community
  • 1
  • 1
Bhavin Rana
  • 1,554
  • 4
  • 20
  • 40
0

You can always add reply to mail address which will take care if there is any error so you will get email back, and for if it's read, include a picture (blank picture of 1 pixel will do) and add code in that picture like and you can see how many hits that image did recieve or recieved any at all.

0

You can check that things in two different ways like, by using the header "Disposition-Notification-To" to your mail function, it will not going to work in all case because most people choose not to send read receipts. If you could, from your server, influence whether or not this happened, a spammer could easily identify active and inactive email addresses quite easily. You can set header like

$email_header .= "Disposition-Notification-To: $from"; 
$email_header .= "X-Confirm-Reading-To: $from";

now the another method to check is by placing an image and you can add a script to onload of that image, that script will send notification to your system that xxx user have read the mail so, in that way you can track delivery status of the mail.

In fact, I can't think of any way to confirm it's been delivered without also checking it gets read, either by including a image that is requested from your server and logged as having been accessed, or a link that the user must visit to see the full content of the message.

Neither are guaranteed (not all email clients will display images or use HTML) and not all 'delivered' messages will be read.

Though for more info https://en.wikipedia.org/wiki/Email_tracking

Yuvraj Jain
  • 183
  • 10
  • $mail->ConfirmReadingTo = "someone@something.com"; is added this line in to my code but still i am not getting any confirmation. what kind of changes still i am missing. if anyone know please help me out. – Jigar Oza Apr 06 '13 at 07:12
  • @JigarOza: can you share your code here, I will make that code working for you, because without checking the code I cannot have any idea why you are not getting confirmation regarding the mails. – Yuvraj Jain Apr 06 '13 at 08:29
  • @JigarOza like Yuvraj stated in his answer, it is up to the user to send a read receipt and most users choose not to. I know I rarely send those back. That may be why you are not getting a confirmation. Test it by sending an email to yourself. – Tash Pemhiwa Aug 23 '13 at 11:10