0
<?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.";
?>

嘿,伙计们在这里需要帮助!我希望当有人按下提交按钮时,它会保存输入的详细信息并将其发送到电子邮件中

4

3 回答 3

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.";


    }
    ?>
于 2013-08-06T04:57:14.257 回答
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.';
    }
?>
于 2013-08-06T05:01:50.787 回答
0

如果您仍在运行 WAMPServer,那么您在 Windows PC 上。

Window 没有附带邮件服务器,mail()除了将邮件传递到邮件服务器之外,该功能几乎没有其他作用。

您将需要安装邮件服务器,它们确实存在于 Windows 中,但这对于初学者来说并不是一项简单的任务。

或者,看看phpMailer哪个可以用来发送邮件,基本上是背一个现有的电子邮件帐户,比如你的雅虎或 gmail 帐户之一

于 2016-01-29T11:22:34.960 回答