<?php
echo $this->Form->end(__('Submit'))
$to = "someone@hotmail.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.";
?>
嘿伙计们在这里需要帮助!我想当有人按下提交按钮时,它会保存并将输入的详细信息发送到电子邮件
答案 0 :(得分:1)
你必须这样使用。确保你的按钮类型是提交
<?php
if($_POST){
$to = "someone@hotmail.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.";
}
?>
答案 1 :(得分:0)
尝试以下代码,
<?php
if(isset($_POST['submit'])){ // check if submit button is pressed
$to = "someone@hotmail.com"; $subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
if(mail($to,$subject,$message,$headers))
echo "Mail Sent.";
else
echo 'Error while sending mail.';
}
?>
答案 2 :(得分:0)
如果您仍在运行WAMPServer,那么您使用的是Windows PC。
窗口没有邮件服务器,mail()
功能除了将邮件传递到邮件服务器之外别无其他功能。
您需要安装一个邮件服务器,它们确实存在于Windows中,但这对初学者来说不是一个简单的任务。
或者,查看可用于发送邮件的phpMailer
,并基本上背负现有的电子邮件帐户,例如您的yahoo或gmail帐户