duanci9305
2013-05-16 23:19
浏览 160
已采纳

通过PHP发送注册表单结果到电子邮件地址[关闭]

I have a question about PHP email function, I hope you can help me with this. I have little to no experience in PHP.

Ive set up a web page, where users can submit following info via the HTML form: Name, Email, Phone, and couple Drop Down Selectors.

I have created an empty form.php and when clicked on submit, it gets connected to that php file. Thing is, I want the results to be mailed to my email address WIHOUT mysql database, as far as I know this is possible with PHP, but I couldnt find any tutorial for this.

Can you give me any pointers or guides please, how can I do it ?

Thanks in advance Cheers : ))

EDIT: I forgot to mention, with some PHP tutorials, I managed to send the mail to my email address, and managed to get the email subject correctly, but I couldnt get the results of email in the body of the email sent, body is always empty.

Can you please give me an example script, how I could get the results of this form in the body of message? Most tutorials show how to get $message in the body, but I dont really have any text to send via $message. I simply have couple text fields and couple drop down selectors.

图片转代码服务由CSDN问答提供 功能建议

我对PHP电子邮件功能有疑问,希望你能帮我解决这个问题。 我几乎没有PHP的经验。

我已经设置了一个网页,用户可以通过HTML表单提交以下信息: 名称,电子邮件,电话和成对的下拉选择器。

我创建了一个空的form.php,当点击提交时,它连接到该php文件。 事情是,我希望结果邮寄到我的电子邮件地址WIHOUT mysql数据库,据我所知这可以用PHP,但我找不到任何教程。

请您给我任何指示或指南,我该怎么办?

提前致谢 行情人员:))

编辑:我忘了提及,通过一些PHP教程,我设法将邮件发送到我的电子邮件地址,并设法正确地获取电子邮件主题,但我无法在正文中获得电子邮件的结果 发送的电子邮件,正文总是空的。

您能否给我一个示例脚本,如何在消息正文中获取此表单的结果? 大多数教程都展示了如何在正文中获取$ message,但我真的没有任何文本可以通过$ message发送。 我只有几个文本字段和几个下拉选择器。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dqlm80253 2013-05-17 00:13
    已采纳

    Just try this:

    <?php
    $to = "someone@example.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 "Mail not sent";
    }
    ?>
    

    EDIT: 1: soneonelse@example.com; and 'someonelse@example.com are just two different email, like it mentions about the sender and the receiver of the email So, make sure to change the email I have given above to the email you want to send.

    2: If you want to style <div> then do something like this:

     echo "<div style='color:white; background-color:red; font-size:14px; padding:20px; 
     border:1px solid black;'> Mail Sent</div>";
    
    已采纳该答案
    打赏 评论
  • dpq59734 2013-05-16 23:25

    Use mail() function:

    mail($to, $subject, $message);
    

    Details in manual: http://php.net/manual/en/function.mail.php

    打赏 评论

相关推荐 更多相似问题