单击发送电子邮件 [英] Send email on click

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

问题描述

我是一名摄影师,并使用我的网站与我的客户分享照片。我总是将它们链接到受密码保护的目录,在那里他们可以浏览和下载文件。

I'm a photographer and use my website to share photographs with my clients. I always link them to a password protected directory where they can browse and download the files.

我想在下载照片时收到确认电子邮件。

I would like to receive a confirmation email when they have downloaded the photo's.

因此,当他们点击某个特定元素时,我想给自己发送一封电子邮件。如何编写这个代码?

So when they click on a specific element I want to send an email to myself. How would I code this?

推荐答案

如果您想按@Robert建议做一个简单的ajax请求 - 一个名为 mail.php 或类似的文件,类似于下面的文件。

If you want to make a simple ajax request as @Robert suggested - make your php script in a file called mail.php or something, similar to below..

<?php 

mail("youremail@yourdomain.com", $_POST['subject'], $_POST['message']);

?>

然后在您希望用户下载的页面上 - 检测点击并触发ajax像这样打电话。

And then on the page that you want the user to download from - detect the click and trigger an ajax call like this..

<script>

$('#element').click(function(){

    $.ajax({
      type: "POST",
      url: "mail.php",
      data: { subject: "Someone Downloaded Their Photos", message: "Email Content" }
    });

});

</script>

您可以替换jquery中的主题和消息,以便在电子邮件中发送关于您的用户的信息,所以你知道他们是谁,他们正在下载哪些照片。

You could replace the subject and message in the jquery to send information about your user in the email, so you know who they are and which photos they are downloading.

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

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