Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know mail is send and read by user when sending mail using SMTP,PHPmailer

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.

like image 983
Jigar Oza Avatar asked Apr 06 '13 05:04

Jigar Oza


People also ask

How do I know if PHPMailer is working?

to check if it is sending mail as intended; <? php $email = "[email protected]"; $subject = "Email Test"; $message = "this is a mail testing email function on server"; $sendMail = mail($email, $subject, $message); if($sendMail) { echo "Email Sent Successfully"; } else { echo "Mail Failed"; } ?>

Does PHPMailer use SMTP?

PHPMailer is the classic email sending library for PHP. It supports several ways of sending email messages such as mail(), Sendmail, qmail, and direct dispatch to SMTP servers. In addition, it provides a list of advanced features: SMTP authentication.

What is PHPMailer used for?

PHPMailer is a code library and used to send emails safely and easily via PHP code from a web server. Sending emails directly via PHP code requires a high-level familiarity to SMTP standard protocol and related issues and vulnerabilities about Email injection for spamming.

How do I stop emails going to spam in PHPMailer?

usually this happens because the sending server is already marked as spam by somebody. The way i found is go to the gmail account mark the item as 'important' in gmail and 'Add to Safe senders' in Outlook. Show activity on this post. if this is your full codes then you have to write the path of the PHPMailer thats it.


1 Answers

<?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("[email protected]","SOMEONE");

        $mail->From       = "[email protected]";
        $mail->FromName   = "SOMEONE";

        $to = "[email protected]";

        $mail->AddAddress($to);

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

        $mail->ConfirmReadingTo = "[email protected]"; //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 ([email protected], SOMEONE)

  3. Set the correct TO address

from

also

  1. Delivery reports and read receipts in PHP mail
like image 115
Bhavin Rana Avatar answered Sep 17 '22 16:09

Bhavin Rana