我的PHP脚本不会发送正确的电子邮件

时间:2014-12-16 06:17:45

标签: php html

我为在线构建的在线应用程序创建了一个php脚本。代码似乎能够发送电子邮件,但我收到的电子邮件不包含填写到在线应用程序中的任何信息。我不确定有什么问题......

帮助!

HTML

<html>
<p align="left"><form action="application.php" method="get" enctype="multipart/form-data" name="JobApp" lang="en">
<div align="left"><strong>Personal Details</strong></div>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="25%" align="right" valign="top"><span id="sprytextfield1">
      <label for="fullname">Full Name:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td width="35%" align="left" valign="top"><input name="fullname" type="text" id="fullname" size="35" maxlength="100"></td>
    <td width="40%" align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="sprytextfield2">
      <label for="address">Street Address:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><input name="address" type="text" id="address" size="35"></td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="sprytextfield3">
      <label for="city">City:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><input name="city" type="text" id="city" size="30"></td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="spryselect1">
      <label for="province">Province:*</label>
      <span class="selectRequiredMsg">Please select an item.</span></span></td>
    <td align="left" valign="top"><select name="province" id="province">
    <option selected>Choose...</option>
      <option value="Alberta">Alberta</option>
      <option value="British Columbia">British Columbia</option>
      <option value="Manitoba">Manitoba</option>
      <option value="New Burnswick">New Burnswick</option>
      <option value="Newfoundland and Labrador">Newfoundland and Labrador</option>
      <option value="Nova Scotia">Nova Scotia</option>
      <option value="Ontario">Ontario</option>
      <option value="Others">Others</option>
      <option value="Prince Edward Island">Prince Edward Island</option>
      <option value="Quebec">Quebec</option>
      <option value="Saskatchewan">Saskatchewan</option>
    </select></td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="sprytextfield4">
      <label for="postal">Postal Code:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><input name="postal" type="text" id="postal" size="15" maxlength="7"></td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="sprytextfield5">
      <label for="email">Email Address:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><input name="email" type="text" id="email" size="35"></td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="sprytextfield6">
      <label for="phone">Phone Number:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><input name="phone" type="text" id="phone" size="25"></td>
    <td align="left"><span id="spryradio1">
      <label>
        <input type="radio" name="phonetype" value="Cell Phone" id="phonetype_0">
        Cell Phone</label>
      <br>
      <label>
        <input type="radio" name="phonetype" value="Home Phone" id="phonetype_1">
        Home Phone</label>
      <br>
      <span class="radioRequiredMsg">Please make a selection.</span></span></td>
  </tr>
</table>


<p><div align="left"><strong> Relevant Experience</strong></div>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="25%" align="right" valign="top"><span id="spryselect2">
      <label for="position">Position of Interest:*</label>
      <span class="selectRequiredMsg">Please select an item.</span></span></td>
    <td width="75%" align="left" valign="top"><select name="position" id="position">
    <option selected>Choose...</option>
      <option value="Director Information Technology">Director Information Technology</option>
      <option value="Director Public Relations">Director Public Relations</option>
      <option value="Logistics Coordinator">Logistics Coordinator</option>
      <option value="Staff Coordinator">Staff Coordinator</option>
    </select>
    </td>
  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td align="justify" valign="top"><span id="sprytextarea1">
      <label for="experience">What relevant experiences do you have to the position or conference?*</label>
      <span class="textareaRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><textarea name="experience" id="experience" cols="90" rows="10"></textarea></td>
  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td align="justify" valign="top"><span id="sprytextarea2">
      <label for="skills">What skills or qualities do you have that would be an asset to the conference?*</label>
      <span class="textareaRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><textarea name="skills" id="skills" cols="90" rows="10"></textarea></td>
  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td align="justify" valign="top"><span id="sprytextarea3">
      <label for="vision">What vision or ideas do you have for the conference or WTR?*</label>
      <span class="textareaRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><textarea name="vision" id="vision" cols="90" rows="10"></textarea></td>
  </tr>
</table></p>


<p><div align="left"><strong>Required Documents</strong></div>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="25%" align="right" valign="top"><label for="resume">Resume:*</label></td>
    <td width="75%" align="left" valign="top"><input type="file" name="resume" id="resume"></td>
  </tr>
  <tr>
    <td align="right" valign="top"><label for="letter">Cover Letter:*</label></td>
    <td align="left" valign="top"><input type="file" name="letter" id="letter"></td>
  </tr>
</table>


<p><div align="left"><strong>Additional Information</strong></div>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="25%" align="justify" valign="top"><label for="information">Do you have any additional information that may help us understand your your fit better?</label></td>
    <td width="75%" align="left" valign="top"><textarea name="information" cols="90" rows="10" id="information"></textarea></td>
  </tr>
</table>

<p><table width="100%" border="0" cellspacing="0" cellpadding="6">
  <tr>
    <td width="50%" align="right"><input name="clear" type="reset" value="Clear Application"></td>
    <td width="50%" align="left"><input name="submit" type="submit" id="submit" onClick="MM_validateForm('fullname','','R','address','','R','city','','R','postal','','R','email','','RisEmail','phone','','R','experience','','R','skills','','R','vision','','R');return document.MM_returnValue" value="Submit Application"></td>
  </tr>
</table>
</p>

</form></p>
</html>

PHP

    <?php

/* Subject and Email Variables */

    $Position = $_POST['position'];
    $emailSubject = "Application for $Position";
    $emailreply = 'WTR Technology Application Confirmation';
    $webMaster = 'shadi@wtr-tech.com';
    $applicant = $_POST['email'];

/* Gathering Data Variables */

    $Name = $_POST['fullname'];
    $Address = $_POST['address'];
    $City = $_POST['city'];
    $Province = $_POST['province'];
    $Postal = $_POST['postal'];

    $Email = $_POST['email'];
    $PhoneNumber = $_POST['phone'];
    $PhoneType = $_POST['phonetype'];

    $Experience = $_POST['experience'];
    $Skills = $_POST['skills'];
    $Vision = $_POST['vision'];

    $Resume = $_FILES['resume'];
    $CoverLetter = $_FILES['letter'];
    $Information = $_POST['information'];

/* Email sent to WTR Technology */

    $body = <<<EOD
PERSONAL DETAILS
<br><hr><hr><br>
Full Name: $Name <br>
<br>
Street Address: $Address <br>
City: $City <br>
Province: $Province <br>
Postal Code: $Postal <br>
<br>
Email address: $Email <br>
Phone Number ($PhoneType): $PhoneNumber <br>
<br>
<br>
RELEVANT EXPERIENCE
<br><hr><hr><br>
Position of Interest: $Position <br>
<br>
What relevant experiences do you have to the position or conference? <br><hr><br>
$Experience <br>
<br>
What skills or qualities do you have that would be an asset to the conference? <br><hr><br>
$Skills <br>
<br>
What vision or ideas do you have for the conference or WTR Technology? <br><hr><br>
$Vision <br>
<br>
<br>
REQUIRED DOCUMENTS
<br><hr><hr><br>
Resume: $Resume <br>
Cover Letter: $CoverLetter <br>
<br>
<br>
ADDITIONAL INFORMATION
<br><hr><hr><br>
Do you have any additional information that may help us understand your your fit better'?' <br><hr><br>
$Information <br>
EOD;

    $bodyreply = <<<EOD
<br>
Dear $Name,<br>
<br>
Your employment application at The WTR Technology has been successfully submitted.  Applications are delivered to our recruiting staff daily and are reviewed as soon as possible. Please note that changes cannot be made to your application after submittal. Should you need to modify any data or add additional documents to your application, please work with your recruiting coordinator once they have contacted you.  Thank you for your interest in an employment at WTR Technology. <br>
<br>
Best Regards <br>
<br>
<br>
<br><hr><br>
WTR Technology <br>
<br>
This e-mail message may contain confidential and/or privileged information.
If you are not an addressee or otherwise authorized to receive this message,
you should not use, copy, disclose or take any action based on this e-mail or
any information contained in the message. If you have received this material
in error, please advise the sender immediately by reply e-mail and delete this
message. Thank you.
EOD;

    $headers = "From: $webMaster\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body, $headers);
?>

4 个答案:

答案 0 :(得分:1)

您的表单方法设置为&#34; get&#34;。

<form action="application.php" method="post" enctype="multipart/form-data" name="JobApp" lang="en">

按上述方式更改为帖子。

答案 1 :(得分:0)

您的form method设置为获取,并且您正在使用发布。将您的表单方法更改为发布

<form action="application.php" method="post" enctype="multipart/form-data" name="JobApp" lang="en">

答案 2 :(得分:0)

您的表单操作获取您的脚本正在寻找他们需要匹配的帖子

答案 3 :(得分:0)

试试这整个代码......

<?php 
if($_POST)
{
	/* Subject and Email Variables */

    $Position = $_POST['position'];
    $emailSubject = "Application for $Position";
    $emailreply = 'WTR Technology Application Confirmation';
    $webMaster = 'shadi@wtr-tech.com';
    $applicant = $_POST['email'];

/* Gathering Data Variables */

    $Name = $_POST['fullname'];
    $Address = $_POST['address'];
    $City = $_POST['city'];
    $Province = $_POST['province'];
    $Postal = $_POST['postal'];

    $Email = $_POST['email'];
    $PhoneNumber = $_POST['phone'];
    $PhoneType = $_POST['phonetype'];

    $Experience = $_POST['experience'];
    $Skills = $_POST['skills'];
    $Vision = $_POST['vision'];

    $Resume = $_FILES['resume'];
    $CoverLetter = $_FILES['letter'];
    $Information = $_POST['information'];

/* Email sent to WTR Technology */

    $body = "PERSONAL DETAILS
			<br><hr><hr><br>
			Full Name: $Name <br>
			<br>
			Street Address: $Address <br>
			City: $City <br>
			Province: $Province <br>
			Postal Code: $Postal <br>
			<br>
			Email address: $Email <br>
			Phone Number ($PhoneType): $PhoneNumber <br>
			<br>
			<br>
			RELEVANT EXPERIENCE
			<br><hr><hr><br>
			Position of Interest: $Position <br>
			<br>
			What relevant experiences do you have to the position or conference? <br><hr><br>
			$Experience <br>
			<br>
			What skills or qualities do you have that would be an asset to the conference? <br><hr><br>
			$Skills <br>
			<br>
			What vision or ideas do you have for the conference or WTR Technology? <br><hr><br>
			$Vision <br>
			<br>
			<br>
			REQUIRED DOCUMENTS
			<br><hr><hr><br>
			Resume: $Resume <br>
			Cover Letter: $CoverLetter <br>
			<br>
			<br>
			ADDITIONAL INFORMATION
			<br><hr><hr><br>
			Do you have any additional information that may help us understand your your fit better'?' <br><hr><br>
			$Information <br>
			";

    $bodyreply = "
				<br>
				Dear $Name,<br>
				<br>
				Your employment application at The WTR Technology has been successfully submitted.  Applications are delivered to our recruiting staff daily and are reviewed as soon as possible. Please note that changes cannot be made to your application after submittal. Should you need to modify any data or add additional documents to your application, please work with your recruiting coordinator once they have contacted you.  Thank you for your interest in an employment at WTR Technology. <br>
				<br>
				Best Regards <br>
				<br>
				<br>
				<br><hr><br>
				WTR Technology <br>
				<br>
				This e-mail message may contain confidential and/or privileged information.
				If you are not an addressee or otherwise authorized to receive this message,
				you should not use, copy, disclose or take any action based on this e-mail or
				any information contained in the message. If you have received this material
				in error, please advise the sender immediately by reply e-mail and delete this
				message. Thank you.
				";

    $headers = "From: $webMaster\r\n";
    $headers .= "Content-type: text/html\r\n";
	//echo $body;
    $success = mail($webMaster, $emailSubject, $body, $headers);
}
?>
<html>
<p align="left"><form action="" method="post" enctype="multipart/form-data" name="JobApp" lang="en">
<div align="left"><strong>Personal Details</strong></div>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="25%" align="right" valign="top"><span id="sprytextfield1">
      <label for="fullname">Full Name:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td width="35%" align="left" valign="top"><input name="fullname" type="text" id="fullname" size="35" maxlength="100"></td>
    <td width="40%" align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="sprytextfield2">
      <label for="address">Street Address:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><input name="address" type="text" id="address" size="35"></td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="sprytextfield3">
      <label for="city">City:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><input name="city" type="text" id="city" size="30"></td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="spryselect1">
      <label for="province">Province:*</label>
      <span class="selectRequiredMsg">Please select an item.</span></span></td>
    <td align="left" valign="top"><select name="province" id="province">
    <option selected>Choose...</option>
      <option value="Alberta">Alberta</option>
      <option value="British Columbia">British Columbia</option>
      <option value="Manitoba">Manitoba</option>
      <option value="New Burnswick">New Burnswick</option>
      <option value="Newfoundland and Labrador">Newfoundland and Labrador</option>
      <option value="Nova Scotia">Nova Scotia</option>
      <option value="Ontario">Ontario</option>
      <option value="Others">Others</option>
      <option value="Prince Edward Island">Prince Edward Island</option>
      <option value="Quebec">Quebec</option>
      <option value="Saskatchewan">Saskatchewan</option>
    </select></td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="sprytextfield4">
      <label for="postal">Postal Code:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><input name="postal" type="text" id="postal" size="15" maxlength="7"></td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="sprytextfield5">
      <label for="email">Email Address:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><input name="email" type="text" id="email" size="35"></td>
    <td align="left">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top"><span id="sprytextfield6">
      <label for="phone">Phone Number:*</label>
      <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><input name="phone" type="text" id="phone" size="25"></td>
    <td align="left"><span id="spryradio1">
      <label>
        <input type="radio" name="phonetype" value="Cell Phone" id="phonetype_0">
        Cell Phone</label>
      <br>
      <label>
        <input type="radio" name="phonetype" value="Home Phone" id="phonetype_1">
        Home Phone</label>
      <br>
      <span class="radioRequiredMsg">Please make a selection.</span></span></td>
  </tr>
</table>


<p><div align="left"><strong> Relevant Experience</strong></div>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="25%" align="right" valign="top"><span id="spryselect2">
      <label for="position">Position of Interest:*</label>
      <span class="selectRequiredMsg">Please select an item.</span></span></td>
    <td width="75%" align="left" valign="top"><select name="position" id="position">
    <option selected>Choose...</option>
      <option value="Director Information Technology">Director Information Technology</option>
      <option value="Director Public Relations">Director Public Relations</option>
      <option value="Logistics Coordinator">Logistics Coordinator</option>
      <option value="Staff Coordinator">Staff Coordinator</option>
    </select>
    </td>
  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td align="justify" valign="top"><span id="sprytextarea1">
      <label for="experience">What relevant experiences do you have to the position or conference?*</label>
      <span class="textareaRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><textarea name="experience" id="experience" cols="90" rows="10"></textarea></td>
  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td align="justify" valign="top"><span id="sprytextarea2">
      <label for="skills">What skills or qualities do you have that would be an asset to the conference?*</label>
      <span class="textareaRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><textarea name="skills" id="skills" cols="90" rows="10"></textarea></td>
  </tr>
  <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td align="justify" valign="top"><span id="sprytextarea3">
      <label for="vision">What vision or ideas do you have for the conference or WTR?*</label>
      <span class="textareaRequiredMsg">A value is required.</span></span></td>
    <td align="left" valign="top"><textarea name="vision" id="vision" cols="90" rows="10"></textarea></td>
  </tr>
</table></p>


<p><div align="left"><strong>Required Documents</strong></div>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="25%" align="right" valign="top"><label for="resume">Resume:*</label></td>
    <td width="75%" align="left" valign="top"><input type="file" name="resume" id="resume"></td>
  </tr>
  <tr>
    <td align="right" valign="top"><label for="letter">Cover Letter:*</label></td>
    <td align="left" valign="top"><input type="file" name="letter" id="letter"></td>
  </tr>
</table>


<p><div align="left"><strong>Additional Information</strong></div>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="25%" align="justify" valign="top"><label for="information">Do you have any additional information that may help us understand your your fit better?</label></td>
    <td width="75%" align="left" valign="top"><textarea name="information" cols="90" rows="10" id="information"></textarea></td>
  </tr>
</table>

<p><table width="100%" border="0" cellspacing="0" cellpadding="6">
  <tr>
    <td width="50%" align="right"><input name="clear" type="reset" value="Clear Application"></td>
    <td width="50%" align="left"><input name="submit" type="submit" id="submit" onClick="MM_validateForm('fullname','','R','address','','R','city','','R','postal','','R','email','','RisEmail','phone','','R','experience','','R','skills','','R','vision','','R');return document.MM_returnValue" value="Submit Application"></td>
  </tr>
</table>
</p>

</form></p>
</html>

在上面的代码中,我已经尝试了,它会在你的收件箱中给你正确的邮件,你现在只需要为附件文件的所需文件完成代码。我认为你可以用你自己的方式做到这一点,如果你不能发布我会给你解决方案...

在邮件中你现在可以获得Resume:Array和cover Letter:Array,因为你必须编写你存储的文件位置路径.... 多数民众赞成!!!! ..试试这个

创建php文件并将上述代码复制并粘贴到该文件中并运行,然后检查您的电子邮件,无论您在此行中使用过什么:$ webMaster ='shadi@wtr-tech.com'; // abc@yyy.com或任何你想要的东西