How to send an email notification when a page is visited?(如何在访问页面时发送电子邮件通知?)
本文介绍了如何在访问页面时发送电子邮件通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果访问某个页面,是否可以发送电子邮件通知?
(触发一封电子邮件,说该页面已被查看)
Is there a way to send an email notification if a certain page is visited?
(Triggers an email saying the page was viewed)
即.用户来到这个页面:thank-you.php
页面加载后,电子邮件会自动发送给网站管理员.
然后,在发送此电子邮件触发器后,用户会立即被重定向到另一个页面.
Ie. User comes to this page: thank-you.php
And email is automatically sent to the admin of the website upon page load.
Then the user gets redirected to another page right after this email trigger as been sent.
编辑---我需要检查用户是否来自特定的域名或 URL.
这是为了避免漏洞利用或其他杂项.提交技巧.
有什么建议吗?
推荐答案
尝试:
<?php
// The message
$message = "Line 1
Line 2
Line 3";
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send
mail('admin@example.com', 'My Subject', $message);
// Redirect
header('Location: anotherpage.php');
?>
这篇关于如何在访问页面时发送电子邮件通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:如何在访问页面时发送电子邮件通知?
基础教程推荐
猜你喜欢
- php中的PDF导出 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- php中的foreach复选框POST 2021-01-01
