用php和html发送邮件

用php和html发送邮件,php,html,email,post,iframe,Php,Html,Email,Post,Iframe,我使用phpmailer发送普通的预定义邮件,它工作正常。 现在我想做的是,将我的文本编辑器与php脚本连接起来,这样我就可以发送非常好的html邮件。 Texteditor是来自CKEditor的模板。 我在textedtior中编写的所有内容都是用如下html标记编写的 然后我从phpmailer获得了我的php脚本来发送邮件。我一直在考虑是否将所有html标记作为post方法发布,并将它们放在我的php脚本中。也许这不是最好的主意,即使是这样,我也不知道如何从输入标签中发布内容 任何帮

我使用phpmailer发送普通的预定义邮件,它工作正常。 现在我想做的是,将我的文本编辑器与php脚本连接起来,这样我就可以发送非常好的html邮件。 Texteditor是来自CKEditor的模板。

我在textedtior中编写的所有内容都是用如下html标记编写的

然后我从phpmailer获得了我的php脚本来发送邮件。我一直在考虑是否将所有html标记作为post方法发布,并将它们放在我的php脚本中。也许这不是最好的主意,即使是这样,我也不知道如何从输入标签中发布内容

任何帮助都将不胜感激

附言。 这是我的php代码

date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "??????@gmail.com";
$mail->Password = "?????";
$mail->setFrom('????@gmail.com', 'First Last');
$mail->addReplyTo('????@gmail.com', 'First Last');
$mail->addAddress('???@gmail.com', 'John Doe');
$mail->Subject = 'PHPMailer GMail SMTP test';
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
$mail->AltBody = 'This is a plain-text message body';
$mail->addAttachment('images/phpmailer_mini.png');
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}
关于html代码。。很多都是通过模板中的脚本完成的

<html>
<head>
    <meta charset="utf-8">
    <title>???</title>
    <script src="../ckeditor.js"></script>
    <script src="js/sample.js"></script>
    <link rel="stylesheet" href="css/samples.css">
    <link rel="stylesheet" href="toolbarconfigurator/lib/codemirror/neo.css">
</head>
<body id="main">


<form class="newsletter-signup" form action="http://??????gmail.php" method="post">
<main>
        <div class="adjoined-top">
            <div class="grid-container">
                <div class="grid-width-100">
                    <div id="editor">
                    </div>
                </div>
            </div>
        </div>  
</main>


<input type="submit" class="btn btn-default btn-sand" value="subscribe">
</form>
<button onclick="loadPages()">Click Me</button>
<script>
    function loadPages(){
        //document.getElementsByClassName('lulul')[0].setAttribute('src', "http://??????/gmail.php");
        document.getElementsByClassName('lulul')[0].setAttribute('name',"content");
    }
</script>
<script>
    initSample();
</script>

</body>
</html>

???
点击我
函数loadPages(){
//document.getElementsByClassName('lulul')[0].setAttribute('src',“http://?????/gmail.php”);
document.getElementsByClassName('lulul')[0].setAttribute('name','content');
}
initSample();

基本上,其主要思想是使用完整的html正文来正确查看所有html输出。下面是一个例子

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
        This is the body text<br>
<div class="moz-signature"><i><br>
<br>
The<br>
Frenks<br>
</i></div>
</body>
</html>

这是正文



法语
这将在邮件正文内容中以正确的方式执行html:)

例如,如果你只通过了这个,这将不起作用

<b>The Frenks</b>
法国人
你能给我们看一下你的代码吗,这样我们就可以帮助你了,而不是基于假设?只要知道HTML代码不会自动翻译成漂亮的HTML电子邮件就行了。很少有电子邮件客户端能够正确地支持所有HTML,如果您同时添加CSS,您将遇到问题。编写正确的HTML电子邮件是一门黑暗的艺术——不是那么简单(至少如果你想让它跨客户端工作的话)设置
$mail->IsHTML(true)我在我的原始问题上贴了额外的代码,因为我不能在评论中贴那么多。