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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?