php - 从评论框发送电子邮件

标签 php html smtp cpanel

我去年在 visual web developer 设计了一个小网站。我使用 smtp 类添加了一个小工具,基本上它允许人们在文本框中写评论,一旦单击“发送”,它就会向我发送他们输入的任何内容的电子邮件。

我现在正在使用 cPanel,据我所知没有 .net 支持(我没有使用专用服务器,它是 linux 共享主机),我怎么能用如此不同的技术编写这样的东西?我不想触及我现有的 CMS,因为我的网站已经完全设计好了,它非常简单且功能强大。

我只需要指出正确的方向。

最佳答案

您可以使用 PHP:

<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

你甚至可以找到一个形式为@ w3schools 的例子

关于php - 从评论框发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3751711/

相关文章:

python - SMTPAuthenticationError-535,b'5.7.8用户名和密码不被接受。 -从Docker发送电子邮件

smtp - 对 nodejs 中的 smtp 邮件服务器有什么建议吗?

.net - 为什么<system.net><mailSettings>中<smtp>元素有 "from"属性?我怎样才能使用它?

php - 按 ID 显示多个用户信息的问题

php - Ajax 和 session 不起作用

html - Bootstrap : Dropdown on top of accordion

html - 有没有办法在 css/html 中设置最小背景大小

javascript - 如何从 URL 中提取 JSON 数据

php - 使用 css 或 php 将文本限制为一定宽度

html - 添加内联水平线