0

I have below code using codeigniter,

$config['mailtype'] ='html';
$config['charset'] = 'iso-8859-1';
$config['protocol'] ='smtp';
$config['smtp_host'] ='mail.DomainName';
$config['smtp_user'] = "UserEmailId";
$config['smtp_pass'] = "UserPassword";
$config['smtp_port'] ='25';
$this->email->clear(TRUE);

$this->email->initialize($config);
$this->email->from($fromemail, $fromname);
$this->email->to( $email_to );
$this->email->return_path("BouceEmailId"); // I have made this function in system/library/email.php. Also changed the mail() -f field from _headers['from'] to _headers['return-path']

$this->email->subject( "Subject" );
$this->email->message( "This is test email" );

$this->email->send();

In above code it sent an email. But it removes the return path that I have set and it just replace it with the from address. I have read some articles that says SMTP sets return path when it delivers.

How can I set Return Path when I use SMTP authentication?

SMTP not allowed to set custom return_path for bounced emails. It automatically sets return_path with from address when delivered.

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
Sachin
  • 1,273
  • 5
  • 16
  • 27

1 Answers1

0

Read Manual CL Email Class

Parameters:
$from (string) – “From” e-mail address $name (string) – “From” display name $return_path (string) – Optional email address to redirect undelivered e-mail to Returns:
CI_Email instance (method chaining)

You can also set a Return-Path, to help redirect undelivered mail:

$this->email->from('you@example.com', 'Your Name', 'returned_emails@example.com');
Saty
  • 22,443
  • 7
  • 33
  • 51
  • The code I have given is working properly. If I do not use the Protocol SMTP then the return path worked that I have set. But when I use the Protocol SMTP then it sets the return path to from address not to my given return path address. – Sachin May 04 '15 at 12:07