9951 explained code solutions for 126 technologies


phpmailerHow do I set the return path in PHPMailer?


The return path is the email address that will receive the bounced emails. To set the return path in PHPMailer, you can use the addCustomHeader() method.

$mail->addCustomHeader('Return-Path', '[email protected]');

This will set the return path to [email protected].

Parts of the code:

  • addCustomHeader() - a method to add a custom header to the email
  • Return-Path - the header name
  • [email protected] - the email address to receive the bounced emails

Helpful links

Edit this code on GitHub