我有一个php代码,用于通过asalimbao@caleduc.com向我的帐户发送电子邮件,我注意到当我输入发件人的电子邮件帐户(例如myaccount@caleduc.com)时,我点击发送,它会被发送到我的帐户。但当我输入发件人的邮件帐户,如@ yahoo @gmail @hotmail等时,它将不会发送到我的帐户。我不知道这里有什么问题,有人可以帮我修改我的代码吗?
这是我的HTML代码(registration.php):
<form class="forms" action="5.php" method="post" name="feedback">
<fieldset>
<ol>
<li class="form-row text-input-row">
<label>Name of school</label>
<input type="text" name="schoolname" class="text-input required"/>
</li>
<li class="form-row text-input-row">
<label>Email</label>
<input type="text" name="email" class="text-input required email"/>
</li>
<li class="form-row text-input-row">
<label>Contact no.</label>
<input type="text" name="number" class="text-input required"/>
</li>
<li class="form-row text-input-row">
<label>Name of participant.</label>
<input type="text" name="participantsname" class="text-input required"/>
</li>
<li class="form-row text-input-row">
<label>Name of Trainer.</label>
<input type="text" name="trainersname" class="text-input required"/>
</li><br />
<!--li class="form-row text-area-row">
<label>Message</label>
<textarea name="message" class="text-area required"></textarea>
</li-->
<li class="form-row hidden-row">
<input type="hidden" name="hidden" value="" />
</li>
<!--li class="form-row text-input-row">
<label>Select a Level</label> <br /> <br />
<input type="radio" id="radio_1" name="toggler" value="Highschool">High School<br>
<input type="radio" id="radio_2" name="toggler" value="Elementray">Elementary
</li---->
<li class="form-row text-input-row">
<div id="error" style="font-size:11px;color:#8C033A; margin-bottom:10px;text-decoration:italic;"></div>
<div class="five-whole" style="border:0px solid green;">
<input class="required" id="radio_1" type="radio" name="radio_group_1" value="1" />High School
<input class="required" id="radio_2" type="radio" name="radio_group_1" value="2" />Elementary
</div>
</li>
<div id="blk-2" class="toHide" style="display:none">
<li class="form-row text-input-row">
<label>Please choose a Category:</label> <br /> <br />
<input type="checkbox" id="MSpowerpoint" name="checkbox_group_1[]" class="checkbox" value="MSpowerpoint Elementary"> MS Powerpoint<br>
<input type="checkbox" id="Quizbee" name="checkbox_group_1[]" class="checkbox" value="Quizbee Elementary"> ICT Quizbee(Two participants)<br>
</li>
</div> <br />
<div id="blk-1" class="toHide" style="display:none">
<li class="form-row text-input-row">
<label>Please choose a Category:</label> <br /><br />
<input type="checkbox" id="Quizbee" name="checkbox_group_1[]" class="checkbox" value="Quizbee High School"> ICT Quizbee(Two participants)<br>
<input type="checkbox" id="webdev" name="checkbox_group_1[]" value="web development High School"> Advanced Web Design using Dreamweaver/xHTML<br>
<input type="checkbox" id="vb8" name="checkbox_group_1[]" value="vb 2008 High School"> Visual Basic 2008<br>
<input type="checkbox" id="Photoshop" name="checkbox_group_1[]" class="checkbox" value="Photoshop High School"> Photoshop<br>
<input type="checkbox" id="Flash" name="checkbox_group_1[]" class="checkbox" value="Flash High School"> Adobe Flash<br>
<input type="checkbox" id="PCAssembly" name="checkbox_group_1[]" class="checkbox" value="PC Assembly High School"> PC Assembly and Troubleshooting<br>
<input type="checkbox" id="Photography" name="checkbox_group_1[]" class="checkbox" value="Photography High School"> Digital Photography<br> <br>
</li><br />
</div>
<li class="button-row">
<input type="submit" name="send_message" onClick="ValidateForm(this.form)" value="Send" class="btn-submit" />
</li>
</ol>
<input type="hidden" name="v_error" id="v-error" value="Required" />
<input type="hidden" name="v_email" id="v-email" value="Enter a valid email" />
</fieldset>
</form>
这是我的php代码(5.php):
<?php
$mail_to = 'example@caleduc.com'; // specify your email here
// Assigning data from $_POST array to variables
$name = $_POST['schoolname'];
$mail_from = $_POST['email'];
$phone = $_POST['number'];
$participant = $_POST['participantsname'];
$trainersname = $_POST['trainersname'];
$Level = $_POST['radio_group_1'];
$category = implode(' | ', $_POST['checkbox_group_1']);
// Construct subject of the email
$subject = 'www.caledtech.com/batlle Message from visitor ' . $name;
// Construct email body
$body_message = 'From: ' . $name . "\r\n";
$body_message .= 'E-mail: ' . $mail_from . "\r\n";
$body_message .= 'Phone: ' . $phone . "\r\n";
$body_message .= 'Trainer: ' . $trainersname. "\r\n";
$body_message .= 'Name of Participants: ' . $participant . "\r\n";
$body_message .= 'Level: ' . $Level . '.' . "\r\n";
$body_message .= 'category: ' . $category . "\r\n";
// Construct headers of the message
$headers = 'From: ' . $mail_from . "\r\n";
$headers .= 'Reply-To: ' . $mail_from . "\r\n";
$mail_sent = mail($mail_to, $subject, $body_message, $headers);
if ($mail_sent == true){ ?>
<script language="javascript" type="text/javascript">
alert('Thank you for registering!. We will contact you shortly. If in case you dont recieved any message from us, please use the contact form or send us an email @ example@caleduc.com');
window.location = 'registration.php';
</script>
<?php } else { ?>
<script language="javascript" type="text/javascript">
alert('Message not sent. Please, notify site administrator myaccount@caleduc.com');
window.location = 'registration.php';
</script>
<?php
}
&GT;
我已上传并尝试在线发送电子邮件,但如果发件人的电子邮件字段包含@ yahoo / @ gmail / @ hotmail或任何非@caleduc的电子邮件,则无法发送邮件。有人请帮帮我。