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

通过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.

  • 写回答

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>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 怎样才能让鼠标沿着线条的中心线轨迹移动
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?