我正在使用php表单从我的网站发送电子邮件,但它不起作用。我试图从服务器(ubuntu)发送它。我没有得到什么问题。
如果有人能帮助我,我将不胜感激。
这是php代码: contactinfo.php
---<html>
<head>
<title>Sending HTML email using PHP</title>
</head>
<body>
<?php
$to = "xyz@gmail.com";
$subject = "This is subject";
$message = "<b> First Name :".$_POST['fname']."</b>";
$message = "<b> Last Name :".$_POST['lname']."</b>";
$message .= "<h1>Email ".$_POST['email'].".</h1>";
$message .= "<h1>Website ".$_POST['website'].".</h1>";
$message .= $_POST['message'];
$header = "From:qwerty@gmail.io \r\n";
$header = "Cc:abc@gmail.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true )
{
echo "Message sent successfully...";
sleep(2);
header("Location: http://xyz.co/"); /* Redirect browser */
exit();
} else {
echo "Message could not be sent...";
sleep(2);
header("Location:http://abc.co/"); /* Redirect browser */
exit();
}
?>
</body>
</html>
这是html代码:
<form id="contact-form" method="post" action="contactinfo.php">
<div class="two_columns_50_50 clearfix">
<div class="column1">
<div class="column_inner">
<input type="text" style="opacity: 0.8;" class="requiredField" name="fname" id="fname" value="" placeholder="First Name *"/>
</div>
</div>
<div class="column2">
<div class="column_inner">
<input type="text" style="opacity: 0.8;" class="requiredField" name="lname" id="lname" value="" placeholder="Last Name *" />
</div>
</div>
</div>
<div class="two_columns_50_50 clearfix">
<div class="column1">
<div class="column_inner">
<input type="text" style="opacity: 0.8;" class="requiredField email" name="email" id="email" value="" placeholder="Email *" />
</div>
</div>
<div class="column2">
<div class="column_inner">
<input type="text" style="opacity: 0.8;" name="website" id="website" value="" placeholder="Website"/>
</div>
</div>
</div>
<textarea name="message" style="opacity: 0.8;" id="message" rows="10" placeholder="Message"></textarea>
<span class="submit_button_contact">
<input class="qbutton contact_form_button" type="submit" value="Contact Us" style="opacity: 0.6; background-color: rgb(255, 255, 255); color: black;" />
</span>
</form>
由于