0

I am using phpmailer for sending emails, but I want to make a custom header for my campaign, by adding a textarea field that contain any custom header here is my code but I don't know where is the problem it not working I don't see my custom header in mail full header:

foreach (preg_split('/[\r\n]+/', $_POST['customHeader']) as $line) {
    list($name, $value) = explode(': ', $line, 2);
    $PHPMailer->addCustomHeader($name,$value);
}

Even I use different headers, I don't see my custom header in recieved mail, please help thanks in advance.

Rasclatt
  • 12,498
  • 3
  • 25
  • 33
jhonee
  • 1
  • 2

1 Answers1

0

To split the line just use explode, and trim it, also phpmailer will split itself if skip value.

$items = explode(chr(10), $_POST['customHeader']);
foreach($items as $line)
    $PHPMailer->addCustomHeader(trim($line));
Shintiger
  • 116
  • 5