提交简单表格,循环发送邮件? [英] Submit simple form, loop and send mail?

查看:99
本文介绍了提交简单表格,循环发送邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我绝对是PHP n00b,所以我可以在一些小片段上使用一些帮助.

I am a absolute PHP n00b, so i could use some help with a small snippet.

我有一个简单的表格,其中包含几个广播和输入字段.一旦它们全部填满并且用户提交了表单,我想通过jQuery AJAX将其提交到PHP文件,该文件将遍历请求中的所有表单元素,将它们添加到字符串中,并将该字符串作为电子邮件(带有预定义的主题)到预定义的电子邮件帐户.您将如何在PHP中完成这个简单的任务?

I have a simple form with a couple of radio and input fields. Once they are all filled and the user submits the form, i want to, via jQuery AJAX, submit it to a PHP file, which loops thorugh all the form elements in the request, adds them to a string, and sends that string as an email (with a predefined subject) to a predefined email account. How would you go about this simple task in PHP?

推荐答案

您可以做类似的事情

<?php
$to = 'asdf@example.com';
$subject = 'website form';
$message= '';
foreach ($_POST as $key => $value)
{
    $message .= $key . ': ' . $value . PHP_EOL;
}
mail($to, $subject, $message);
?>

这篇关于提交简单表格,循环发送邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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