如何使用phpmailer设置自定义标题 [英] How to set a custom header using phpmailer
问题描述
我正在使用phpmailer发送电子邮件,但是我想通过添加一个包含任何自定义标题的textarea字段来为我的公司制作一个自定义标题,例如使用这样一个标题:
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.
推荐答案
你需要做一些发现和修改的默认标头由PHPmailer设置为此可以实现。
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('from@example.com', 'Mailer');
主题:
$mail->Subject = 'Here is the subject';
自定义:
$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.
这篇关于如何使用phpmailer设置自定义标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!