Jump to content

Recommended Posts

Dear All,

 

I'm trying to make a form mail on an Apache 2.2 on Windows server, I have the php.ini file point to the

SMTP server our IT guy provided. But still, the email never come after the form is submitted.

 

I'm not sure if I have missed anything in my code...do I need to tell the handling file to find the SMTP

setting in php.ini?

 

I'm attaching my code here...please kindly let me know if anything should be changed. Or if the code

seems fine...Appreciate whole lot!!!

 

<?php

    //change this to your email
    $to = "[email protected]";
    $from = $_POST['email'];
    $subject = "Audition Application";
$field1 = $_POST['familyname'];
$field2 = $_POST['givenname'];
$field4 = $_POST['dobdd'];
$field5 = $_POST['dobmm'];
$field6 = $_POST['dobyy'];
$field7 = $_POST['age'];
$field8 = $_POST['gender'];
$field9 = $_POST['instrument'];
$field10 = $_POST['birthplace'];
$field11 = $_POST['resicountry'];
$field12 = $_POST['passportnum'];
$field13 = $_POST['passportis'];
$field14 = $_POST['passportex'];
$field15 = $_POST['homeaddr'];
$field16 = $_POST['homephone'];
$field17 = $_POST['mobilephone'];
$field18 = $_POST['email'];
$field19 = $_POST['schoolname'];
$field20 = $_POST['teacher'];
$field21 = $_POST['experience1'];
$field22 = $_POST['experience2'];
$field23 = $_POST['experience3'];
$field24 = $_POST['language'];
$field25 = $_POST['regdd'];
$field26 = $_POST['regmm'];
$field27 = $_POST['regyy'];
$field28 = $_POST['returnname'];
$field29 = $_POST['returnaddr1'];
$field30 = $_POST['returnaddr2'];
$field31 = $_POST['returnaddr3'];


//Dropdown Menu Options	
switch ($_POST['audition']) { 
case 1: 
$audition = 'Bangkok, Thailand'; 
break; 
case 2: 
$audition = 'Beijing, China'; 
break; 
case 3: 
$audition = 'Guangzhou, China'; 
break;
case 4: 
$audition = 'Hanoi, Vietnam'; 
break;
case 5: 
$audition = 'Hong Kong'; 
break;
case 6: 
$audition = 'Kuala Lumpur. Malaysia'; 
break;
case 7: 
$audition = 'Nagoya, Japan'; 
break;
case 8: 
$audition = 'Osaka, Japan'; 
break;
case 9: 
$audition = 'Seoul, Korea'; 
break;
case 10: 
$audition = 'Shanghai, China'; 
break;
case 11: 
$audition = 'Singapore'; 
break;
case 12: 
$audition = 'Taipei, Taiwan'; 
break;
case 13: 
$audition = 'Tokyo, Japan'; 
break;
case 14: 
$audition = 'Other'; 
break; 
default: 
$audition = false; 
break; 
} 
if (!$audition) { 
echo 'Please select a city!'; 
die(); 
}

    //begin of HTML message
    $message = <<<EOF
<html>
<style type="text/css">
.font1 {font-family: "Times New Roman", Times, serif; font-size: 12px; color: #000000;}
</style>
<body>
<table width="528" border="1" bordercolor="#CCCCCC" cellspacing="0" cellpadding="0">
<tr>
    <td height="24"> <font class="font1"><b>Family Name:</b></font></td>
    <td colspan="2"> <font class="font1"><b>Given Name:</b></font></td>
    <td> <font class="font1"><b>Audition City:</b></font></td>
</tr>
<tr>
    <td height="24"> <font class="font1">$field1</font></td>
    <td colspan="2"> <font class="font1">$field2</font></td>
    <td> <font class="font1">$audition</font></td>
</tr>
<tr>
    <td height="24"> <font class="font1"><b>Date of Birth:</b></font></td>
    <td> <font class="font1"><b>Age:</b></font></td>
    <td> <font class="font1"><b>Gender:</b></font></td>
    <td> <font class="font1"><b>Instrument:</b></font></td>
</tr>
<tr>
    <td height="24"> <font class="font1">$field4 / $field5 / $field6</font></td>
    <td> <font class="font1">$field7</font></td>
    <td> <font class="font1">$field8</font></td>
    <td> <font class="font1">$field9</font></td>
</tr>
<tr>
    <td height="24"> <font class="font1"><b>Place of Birth:</b></font></td>
    <td colspan="3"> <font class="font1"><b>Country of Permanent Residence:</b></font></td>
</tr>
<tr>
    <td height="24"> <font class="font1">$field10</font></td>
    <td colspan="3"> <font class="font1">$field11</font></td>
</tr>
<tr>
    <td height="24"> <font class="font1"><b>Passport Number:</b></font></td>
    <td colspan="2"> <font class="font1"><b>Passport Issue Date:</b></font></td>
    <td> <font class="font1"><b>Passport Expiry Date:</b></font></td>
</tr>
<tr>
    <td height="24"> <font class="font1">$field12</font></td>
    <td colspan="2"> <font class="font1">$field13</font></td>
    <td> <font class="font1">$field14</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1"><b>Home Address:</b></font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">$field15</font></td>
</tr>
<tr>
    <td height="24"> <font class="font1"><b>Home Phone:</b></font></td>
    <td colspan="2"> <font class="font1"><b>Mobile Phone:</b></font></td>
    <td> <font class="font1"><b>Email:</b></font></td>
</tr>
<tr>
    <td height="24"> <font class="font1">$field16</font></td>
    <td colspan="2"> <font class="font1">$field17</font></td>
    <td> <font class="font1">$field18</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1"><b>School Name:</b></font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">$field19</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1"><b>Major Teacher:</b></font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">$field20</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1"><b>Music Camp/Orchestral Playing Experience:</b></font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">1.</font> <font class="font1">$field21</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">2.</font> <font class="font1">$field22</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">3.</font> <font class="font1">$field23</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1"><b>Language(s) Spoken:</b></font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">$field24</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1"><b>Date:</b></font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">$field25 / $field26 / $field27</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1"><b>Mailing Address</b></font></td>
</tr>
    <tr>
    <td height="24" colspan="4"> <font class="font1">Name</font></td>
</tr>
    <tr>
    <td height="24" colspan="4"> <font class="font1">$field28</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">Address</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">1.</font> <font class="font1">$field29</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">2.</font> <font class="font1">$field30</font></td>
</tr>
<tr>
    <td height="24" colspan="4"> <font class="font1">3.</font> <font class="font1">$field31</font></td>
</tr>
</table>
</body>
</html>
EOF;

   //end of message
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";
    
    // now lets send the email.
    mail($to, $subject, $message, $headers);

    echo "<html>";
echo "<head>";
echo "<META HTTP-EQUIV='Refresh' CONTENT='3; URL=index.html'>";
echo "</head>";
echo "<body>";
echo "Message has been sent!";
echo "<br />";
echo "You are now being sent back to our website.";
echo "</body>";
echo "</html>";
?>

Link to comment
https://forums.phpfreaks.com/topic/127196-phpini-form-mail-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.