I am using phpmailer for sending emails, but I want to make a custom header for my company, by adding a textarea field that contain any custom header for example using a header like this one:

Subject: __Subject
From: __From
Reply-to: <__Reply-To>
To: __To
Date: __smtpDate

or any other header types.. How can I do this in details please, thanks in advance.

Hi, you can use the addCustomHeader() method, for example:

<form method="POST">
    <input type="text" name="companyName">
</form>

on PHP side you do:

$companyName = sprintf("CompanyName: %s", $_POST['companyName']);
$mail->addCustomHeader($companyName);

Check the syntax at:

And remember always to sanitize the input.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.