Html以HTML页面作为附件发送电子邮件 [英] Html to email with HTML page as attachment

查看:106
本文介绍了Html以HTML页面作为附件发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



我正在尝试通过smtp设置而不是客户端软件将在线表单发送到pdf附件。



是否有我可以用来执行此操作的脚本,我可以调用java脚本,



请帮助



我有adobe pro如果这会有所帮助,或者指导请



我尝试了什么:



一直在寻找答案,并在您的页面上看到这个

函数sendMail()

{

var link =mailto:me@example.com+

?cc = CCaddress@example.com+

& subject = + escape(This is subject)+

& body =+ escape(This is body);

window.location.href = link;

}



我知道这不会做我想要的,但请帮助我。

Hi there

I am trying to send an online form to pdf attachment via smtp settings and not client software.

Is there script that I can use to do this, either java script I can call,

Please help

I have adobe pro if that will help, or guidance please

What I have tried:

Been looking around for answers and saw this on your page
function sendMail()
{
var link = "mailto:me@example.com"+
"?cc=CCaddress@example.com"+
"&subject=" + escape("This is subject")+
"&body=" + escape("This is body");
window.location.href = link;
}

I know this will not do what I want, but please help me.

推荐答案

这是底线:



来自讨论在评论中,您似乎根本没有使用服务器端脚本。不,没有服务器端脚本,您根本无法做任何事情。 JavaScript不发送邮件,它只能通过发送邮件或其他任何内容向服务器端发送HTTP请求。如果你使用HTTP表格,你甚至不需要JavaScript。



使用mailto只是意味着 URI方案,可以在常规中使用的方案。如果在页面上使用此类锚点,则只需加载默认邮件应用程序并将一些命令行参数传递给它。它也无法帮助你。而且,你甚至不能假设用户有任何邮件应用程序。这种技术只不过是提供联系信息并说请自己发送电子邮件,只是为了方便。



所以,你总是需要一些服务器 - 编写和发送邮件的副本脚本。原则上,您可以使用为此目的提供的一些外部服务。我一直都是通过付费订阅运营的服务。很难想象对于拥有自己网站的开发者来说这是有意义的。



从你关于拥有cPanel和1个SQL数据库的回复,我可以得出结论您可能使用或多或少标准的Web托管,也许是LAMP。所有标准托管计划,作为最低限度,支持PHP。这不是最好的语言和服务器端技术,但它提供了一些发送带附件的邮件的最小工具。



以下是使用PHP处理表单的方法: PHP:处理表格 - 手册 [ ^ ]。



发送邮件的两个主要选项:

http ://php.net/manual/en/function.mail.phphttp://php.net/manual/en/function.mail.php [ ^ ],

手动::发送邮件 [ ^ ](要求梨:

    手册::关于PEAR和PEAR2 [ ^ ])。



一般处理表单和发送邮件的主要问题是安全性。处理HTTP Web请求时,必须清理服务器端的所有内容。对于一个非常基本的漏洞,请看我过去的答案:无法发送邮件,它显示以下代码中的错误。 [ ^ ]。



你需要添加代表PDF附件的邮件部分。这只是邮件文本的一部分,具有单独的内容类型内容处置标头。请参阅:

媒体类型 [ ^ ](注意:申请/ pdf),

MIME - 维基百科,免费的百科全书 [< a href =https://en.wikipedia.org/wiki/MIME#Content-Dispositiontarget =_ blanktitle =New Window> ^ ]。



你必须学习所有这些东西才能编写邮件并发送它们。您还需要一个正确设置的SMPT服务器(或其他东西),它通常随您的邮件托管提供。



我不是故意在这里推荐PHP,我写的是因为我不能过多地考虑你的托管环境。您可以使用更好的东西。您可能需要致电您的托管客户服务部门获取建议。



-SA
Here is the bottom line:

From the discussion in comments, it seems that you are not using server-side scripting at all. No, without server-side scripting, you cannot do anything at all. JavaScript does not send mail, it can only send HTTP request to the server side where you serve up such request by sending mail or anything else. If you use HTTP form, you don't even need JavaScript.

"Using mailto" simply means URI scheme, the one which could be used in a regular anchor. If you use such anchor on your page, it will simply load the default mail application and pass some command-line parameters to it. It also cannot help you. Moreover, you cannot even assume that a user has any mail application at all. This technique is nothing but providing contact information and saying "please send e-mail by yourself", only with some minimal convenience.

So, you always need some server-side scripting to compose and send mail. In principle, you can use some external service provided for this purpose. What I were always services operating by paid subscription. It's hard to imagine that it would make any sense for the developers having their own Web sites.

From your reply about having cPanel and 1 SQL database, I can conclude that you probably use more or less standard Web hosting, maybe LAMP. All standard hosting plans, as a bare minimum, support PHP. This is not the best language and server-side technology, but it provides some minimal tool for sending mails with attachments.

Here is how you deal with forms with PHP: PHP: Dealing with Forms — Manual[^].

Two major options for sending mail:
http://php.net/manual/en/function.mail.phphttp://php.net/manual/en/function.mail.php[^],
Manual :: sends a mail[^] (requires PEAR:
   Manual :: About PEAR and PEAR2[^]).

The major problem with handling forms in general and with sending mail is security. You have to sanitize everything on the server side when you handle an HTTP Web request. For one very basic exploit, please see my past answer: unable to send mail , it showing the error in below code .[^].

You need to add mail parts representing PDF "attachment". This is just a part of your mail text with separate content-type and content-disposition headers. Please see:
Media Types[^] (note: "application/pdf"),
MIME — Wikipedia, the free encyclopedia[^].

You have to learn all this stuff to be able to compose mail messages and send them. You also need a properly set up SMPT server (or something else), which is usually provided with your mail hosting.

I don't mean to recommend PHP here, I write about it because I cannot assume too much about your hosting environment. It's possible that you can use something better. You may need to call your hosting customer service for an advice.

—SA


这篇关于Html以HTML页面作为附件发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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