gpt4 book ai didi

java - 简单的邮件列表

转载 作者:行者123 更新时间:2023-12-01 15:56:30 25 4
gpt4 key购买 nike

任何人都可以告诉我有关在页面中编写哪些内容的详细信息吗?

基本上,我需要从头开始构建一个邮件列表,人们可以在其中订阅并将他们添加到邮件列表中。

其背后的 php/javascript 是什么?

最佳答案

邮件列表非常简单。您需要决定如何执行此操作,但一般来说,您会有一个订阅页面和一个帖子页面。我没有测试此代码,因此它可能包含缺陷,但它应该让您了解基于平面文件的邮件列表。

在实际实现中,应该使用MySQL,验证和确认电子邮件,检查错误等。另外,不要忘记这不会验证帖子页面。理想情况下,您需要强大的身份验证来确保您的邮件列表不被泄露。另外要知道,您必须具有取消订阅功能 - 使用 MySQL 比使用平面文件更容易。

订阅.php

<?php
// Has the form been posted?
if(isset($_POST['email']))
{
// Append the submitted e-mail to the list.
$file = fopen('list.txt', 'a');
fputs($file, $_POST['email'] . "\n");
fclose($file);

// Send a message to the browser.
die('Added to mailing list.');
}
?>
<html>
<head>
<title>Subscribe to Mailing List</title>
</head>
<body>
<form action="#" method="post">
<input type="text" name="email" />
<input type="submit" value="Submit" />
</form>
</body>
</html>

post.php

<?php
// Has the form been submitted?
if(isset($_POST['body']))
{
// This should load the file into $lines, as an array of, well, lines.
$lines = file('list.txt');

// For each line, send a message. $line should contain an e-mail address.
foreach($lines as $line)
mail($line, $_POST['subject'], $_POST['body']);

// Send a message to the browser.
die("Message delivered.");
}
?>
<html>
<head>
<title>Post to Mailing List</title>
</head>
<body>
<h1>Post</h1>
<form action="#" method="post">
<input type="text" name="subject" /><br/>
<textarea name="body"></textarea><br/>
<input type="submit" value="Submit" />
</form>
</body>
</html>

关于java - 简单的邮件列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4953538/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com