用PHP生成HTML文档
因此,我正在尝试的是,加快使用Mailchimp发送邮件的过程。 我想通过简单地更改邮件模板中的数据来实现这一点。 我的公司通常是手工完成的,但这需要很多时间。 所以首先,我尝试使用PHP简单地更改我的邮件模板。 问题是,Mailchimp只能读取HTML文档,而完全忽略了PHP。 我尝试了.htaccess在我的HTMLfile中使用PHP,但Mailchimp也不会读取.htaccess文件 问题:我只能加载HTML文件,Mailchimp只能读取HTML代码 我的问题:我可以使用PHP生成HTML文档吗 让我试着更好地解释我的情况。 假设这是我的模板, mail-template.html用PHP生成HTML文档,php,html,mailchimp,Php,Html,Mailchimp,因此,我正在尝试的是,加快使用Mailchimp发送邮件的过程。 我想通过简单地更改邮件模板中的数据来实现这一点。 我的公司通常是手工完成的,但这需要很多时间。 所以首先,我尝试使用PHP简单地更改我的邮件模板。 问题是,Mailchimp只能读取HTML文档,而完全忽略了PHP。 我尝试了.htaccess在我的HTMLfile中使用PHP,但Mailchimp也不会读取.htaccess文件 问题:我只能加载HTML文件,Mailchimp只能读取HTML代码 我的问题:我可以使用PHP生成
邮件模板
品名
产品信息
因此,对于我的邮件,我需要更改每个产品的产品名称和产品信息。
正如我提到的,我不能使用html以外的任何东西,因为我想将我的模板导入Mailchimp
我需要做的是在我的mail-template.html中更改一些产品信息,而不需要任何其他语言来支持它。
我唯一能想到的是使用另一种编码语言生成邮件模板,而不是将生成的文件用作模板
我甚至不确定这是否可能,或者是否有更好的方式我错过了。我对这一切都很陌生,所以这就是我寻求帮助的原因
感谢您的时间。:) 是的,您可以使用php生成html文档
<?php
//Simply store all the html code in a variable as shown below,
$pagehtml = "your html will go here";
?>
您可以使用会话将此变量传递到下一页,也可以简单地创建一个扩展名为.php的页面,并将变量(例如$pagehtml)内容回显到所需位置。是的,php可以做到这一点,快速示例
//create html file for writing
$file = fopen("file.html", "a+") or die ( "File creation failed".error_get_last() );
//add your content to $content variable
$content='<html>
<head>
<title>Mailing-Template</title>
</head>
<body>
<div id="productBox">
<h1 id="productName">Product Name</h1>
<p id="productInfo">product info</p>
</div>
</body>
</html>';
//write the content to the file
fwrite($file, $content);
//close the completed file
fclose($file);
//创建用于写入的html文件
$file=fopen(“file.html”,“a+”)或die(“文件创建失败”。错误为\u get\u last());
//将您的内容添加到$content变量
$content='1
邮件模板
品名
产品信息
';
//将内容写入文件
fwrite($file,$content);
//关闭已完成的文件
fclose($文件);
谢谢大家的帮助!
我知道生成一个HTMLfile,我可以通过在内容中抛出一个变量来更改数据
//create html file for writing
$file = fopen("file.html", "a+") or die ( "File creation failed".error_get_last() );
//set product name
$productName = "Product Name";
//add content to $content variable
$content='
<html>
<head>
<title>Mailing-Template</title>
</head>
<body>
<div id="productBox">
<h1 id="productName">' . $productName . '</h1>
<p id="productInfo">product info</p>
</div>
</body>
</html>';
//write the content to the file
fwrite($file, $content);
//close the completed file
fclose($file);
//创建用于写入的html文件
$file=fopen(“file.html”,“a+”)或die(“文件创建失败”。错误为\u get\u last());
//设置产品名称
$productName=“产品名称”;
//将内容添加到$content变量
$content='1
邮件模板
' . $产品名称。”
产品信息
';
//将内容写入文件
fwrite($file,$content);
//关闭已完成的文件
fclose($文件);
感谢您的帮助:)是的,您可以从PHP创建HTML文件。在变量中生成标记,然后使用file\u put\u contents
生成文件。Dinamicaly OP可以更改产品名称和产品信息的部分在哪里?问题是“我可以使用PHP生成HTML文档吗?”。否问题是:“我想通过简单地更改邮件模板中的数据来实现这一点。我的公司通常是手工完成的,但这需要很多时间“@djaxy My bad,应该让我的问题更清楚。你确实回答了我的问题。@LelioFaieta是对的,但我的实际问题是:“我想通过简单地更改邮件模板中的数据来实现这一点。”。我的公司通常是手工完成的,但这需要很多时间”。
//create html file for writing
$file = fopen("file.html", "a+") or die ( "File creation failed".error_get_last() );
//set product name
$productName = "Product Name";
//add content to $content variable
$content='
<html>
<head>
<title>Mailing-Template</title>
</head>
<body>
<div id="productBox">
<h1 id="productName">' . $productName . '</h1>
<p id="productInfo">product info</p>
</div>
</body>
</html>';
//write the content to the file
fwrite($file, $content);
//close the completed file
fclose($file);