在PHP中的电子邮件div内容 [英] email div content in php

查看:75
本文介绍了在PHP中的电子邮件div内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能取得特定< div> 下的内容并通过电子邮件发送该内容?



<例如:
如果我有这样的事情:

 < div id =1> 
< ul>
< li> a< / li>
< li> b< / li>
< ul>
< / div>

基本上我只想引用< div> 是否有任何方法来缓存div中的内容?
这是否可能? (javascript?php?)



感谢。

解决方案

取决于你有什么进一步的要求。您可以让jQuery脚本将内容发送给PHP脚本,然后通过电子邮件发送给他们:

  $。post(email .php,{data:$(div#1)。html()},function(result){
/ * handle results * /
});

然后您的email.php脚本与以下内容类似(不要使用以下代码是):

 <?php 

$ to = john@doe.com;
$ subject =HTML Data;
$ message = $ _POST [data];
$ headers =发件人:服务器< server@doe.com> 。 \r\\\

Content-type:text / html。 \r\\\
;

邮件($ to,$ subject,$ message,$ headers);

?>


Is it possible to take the content that is under a specific <div> and email that content?

For example: If I have something like this:

<div id="1">
<ul>
 <li>a</li>
 <li>b</li>
<ul>
</div>

Basically I want to just reference <div> and take the whole content and email it. is there any way to cache the contents in the div? Is this anyway possible? ( javascript? php?)

Thanks.

解决方案

It really depends on what further requirements you have. You could have a jQuery script send the contents to a PHP script, which then emails them out:

$.post("email.php", { data : $("div#1").html() }, function(result){
  /* handle results */
});

And then your email.php script looks similar to the following (Don't use the following code as-is):

<?php

  $to = "john@doe.com";
  $subject = "HTML Data";
  $message = $_POST["data"];
  $headers = "From: The Server <server@doe.com>" . "\r\n" .
             "Content-type: text/html" . "\r\n";

  mail($to, $subject, $message, $headers);

?>

这篇关于在PHP中的电子邮件div内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆