-3

我的联系页面上有一个联系表格,它是一个 php 页面。我正在收集用户的请求并尝试将其邮寄到 me@mydomain.com。但是,我尝试了所有不同的方式,但无法使用 php 发送邮件。我对 php 很陌生,我正在努力学习这门语言。这是代码示例。

这是我的 HTML

<h2>Your Details</h2></br>
<div class="form_row">
<input type="text" class="form_input" name="name" id="txtName" placeholder="Your Name"      />
</div>
<div class="form_row">
<input type="text" class="form_input" name="phone" id="txtPhone" placeholder="Phone Number" />
</div>
<div  class="form_row">
<input type="text" class="form_input" name="email" id="txtEmail" placeholder="Email" />
</div>
<div  class="form_row">
<textarea class="form_textarea" name="message" id="txtMessage" placeholder="Provide as much information you can regarding the project."></textarea>
<p><input type="submit" id="submit" class="button" value="Send"/></p>
                                                </div>

这是我的 php 脚本

<?php
    if(isset($_POST['submit']))
    {           
        $to = "harish.upadhyayula@ritchsystems.com";
        $subject = 'Request for quote from - ritch systems website.';
        $from = 'Surekha';
        $phone = '410-555-4988';
        $message = 'Testing php mail by hard coding.';
        $headers =  "From: ".$from."\r\n" .  
                    "Phone: ".$phone;
        ini_set("sendmail_from", $from);
        if(mail( $to, $subject, $message, $headers ))
        {
        echo 'Mail Sent';
        }
        else {echo 'Something is wrong!';}
    }
?>
4

1 回答 1

3

在不在本地主机上的服务器上尝试这种类型(无法在 localhost 上发送邮件)

 $to = 'rsharma@gmail.com';
    $subject = 'Thanks for Registering on Dota Pub Stars!';
    $message = 'your msg';

        $headers = "MIME-Version: 1.0 \r\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1\n"; //sending html
        $headers .= "From: $from\r\n";

mail($to, $subject, $message, $headers);
于 2013-02-01T05:04:38.493 回答