0

I'm using XAMPP and when I send an email with PHP mail() function the subject comes two times (like "hello, hello").

PHP Code:

$from="me@gmail.com"; 
$to="you@gmail.com";
$subject="hello";
$message="this doesn't work nicely";
$headers = 'From: '.$from."\r\n".
        'Subject: '.$subject."\r\n".
         'Mime-Version: 1.0'."\r\n";

mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $headers);

Does anyone know the solution?

Sender
  • 6,660
  • 12
  • 47
  • 66

1 Answers1

0

Looks like the $headers are the issue here:

$from="me@gmail.com";

$to="you@gmail.com";

$subject="hello";

$message="this doesn't work nicely";

mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message,);
Hexana
  • 1,095
  • 2
  • 12
  • 35