访问页面时如何发送电子邮件通知? [英] How to send an email notification when a page is visited?

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

问题描述

如果访问某个页面,是否有办法发送电子邮件通知?

(触发一个电子邮件,表示页面被查看)



即。用户来到这个页面:thank-you.php

电子邮件在页面加载时自动发送到网站的管理员。
然后用户在发送电子邮件触发之后立即重定向到另一个页面。



编辑---
我需要检查用户是否来自特定的域名或URL。
这是为了避免漏洞或其他杂项。提交黑客



任何建议?

解决方案>

尝试:

 <?php 
//消息
$ message = 1号线\\\

//如果我们的任何行大于70个字符,我们应该使用wordwrap()
$ message = wordwrap($ message,70);

//发送
邮件('admin@example.com','我的主题',$ message);

//重定向
header('Location:anotherpage.php');
?>


Is there a way to send an email notification if a certain page is visited?
(Triggers an email saying the page was viewed)

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.

EDIT --- I would need to check if a user came from a specific domain name or URL.
This is to avoid exploits or other misc. submission hacks.

Any suggestions?

解决方案

Try:

<?php
// The message
$message = "Line 1\nLine 2\nLine 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');
?>

这篇关于访问页面时如何发送电子邮件通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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