Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

PHPMailer, return to sender functionality

Posted on 2007-10-05
6
Medium Priority
?
2,414 Views
Last Modified: 2012-08-13
Hello,

  I would like to have email return to sender functionality if the email is not valid, I have tried this code, but it didn't work, any clue about this?

...
                  include("class.phpmailer.php");                  
                  $mail = new PHPMailer();                   
                  $mail->IsMail();
                  
                  $mail->From = $from;
                  $mail->ConfirmReadingTo = $from;
                  $mail->FromName = "";
                  $mail->AddAddress($to);
                  $mail->AddCC($cc);
                  $mail->AddBCC($bcc);
                  $mail->AddReplyTo($from, "");
                  if ($mail->Send())
.....


Regards,
Mohammed
0
Comment
Question by:Mohammed Nasman
  • 2
  • 2
  • 2
6 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 1600 total points
ID: 20025589
You can try adding custom headers like:

 $mail->AddCustomHeader('Return-Path: ' . $from);

0
 
LVL 22

Author Comment

by:Mohammed Nasman
ID: 20026062
I tried it, but I didn't got any return email if I sent to unvalid address
0
 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 1600 total points
ID: 20026836
If you use isMail your local MDA might replace that info when the mail is send through the php-mail-command. Try to use
$mail->isSMTP() instead os $mail->isMail()
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:nplib
ID: 20042724
$mail->Sender = "email@address.exp";
0
 
LVL 22

Author Comment

by:Mohammed Nasman
ID: 20045310
hi nplib, i tried that too after read it in phpmailer doc, but didn't work
i think the problem as hernst42 said, I need to change it to use SMTP, I tried it but got errors, even i put server and username/password

could any one give me a complete sample for sending email with smtp and have the return path?, sorry I'm not good in php, this is just a fix i have to do for part from a big application i have
0
 
LVL 17

Assisted Solution

by:nplib
nplib earned 400 total points
ID: 20049123
if you use $mail->isSMTP();
then you need to have these lines of code;
$mail->IsSMTP();
$mail->Host = "IP ADDRESS of SMPT server";
//If you don't require Authentication on your SMTP server, if its a Public SMTP you shouldn't but
$mail->SMTPAuth = false;
//if you require Authentication then add the following instead
$mail->SMTPAuth = true;
$mail->Username = "administrator";
$mail->Password = "password";
//Obviously use the username and password needed to authenticate on your SMTP server.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question