Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a custom header using phpmailer

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:

exemple of header or any other header types.. How can I do this , thanks in advance.

like image 525
dravos Avatar asked Apr 29 '16 00:04

dravos


People also ask

What is AddReplyTo PHPMailer?

PHPMailer Script to Send Email Using SMTP Authentication From: the sender's email address. FromName: the sender's name. AddAddress: the recipient's email address and name. AddReplyTo: the reply-to email address and name.

Where do I put PHPMailer?

php” file you can use to include the installed libraries, in this case PHPMailer. This file is located under the “vendor” directory by default, although you can configure Composer to use a different directory name.

Is PHPMailer SMTP?

PHPMailer can use a non-local mail server (SMTP) if you have authentication. Further advantages include: It can print various kinds of error messages in more than 40 languages when it fails to send an email. It has integrated SMTP protocol support and authentication over SSL and TLS.


1 Answers

You will need to do some discovery and modification of the default headers set by PHPmailer for this to be achieved.

You will need to use different functions to set/edit headers depending on the type of header you want to set/edit. Here are a few examples:

From:

$mail->setFrom('[email protected]', 'Mailer');

Subject:

$mail->Subject = 'Here is the subject';

Custom:

$mail->addCustomHeader('X-custom-header', 'custom-value');

In short, It is quite an effort to do this when the headers are free-typed in a text box. It is however doable with detection and validation on your side.

like image 172
Henkealg Avatar answered Oct 10 '22 02:10

Henkealg