1 Reply Latest reply on Mar 4, 2010 10:13 AM by Günter Schenk

    php script not sending email

    tbowyer

      I have a simple information request form that should send me an email and redirects to a thank you page when submitted.  It was working and now it has stopped although I have no idea why.  Does anyone have any ideas?  Here is the script.  NOTE: I have changed my email address.

      
      <?php
      $to = 'me@myemailaddress.ca';
      $subject= 
      'MESSAGE FROM DELTA!';
      $all_mailouts = $_POST['all_mailouts'];
      $brochures = 
      $_POST['brochures'];
      $emails_updates_promotions = 
      $_POST['emails_updates_promotions'];
      $safety = $_POST['safety'];
      $hoists = $_POST['hoists'];
      $TypeofUser = $_POST['TypeofUser'];
      $FirstName = $_POST['FirstName'];
      $LastName = 
      $_POST['LastName'];
      $CompanyName = $_POST['CompanyName'];
      $StreetAddress = 
      $_POST['StreetAddress'];
      $City = $_POST['City'];
      $ProvinceState = 
      $_POST['ProvinceState'];
      $PostalZipCode = 
      $_POST['PostalZipCode'];
      $TelephoneNumber = 
      $_POST['TelephoneNumber'];
      $FaxNumber = $_POST['FaxNumber'];
      $EmailAddress 
      = $_POST['EmailAddress'];
      $TheComments = $_POST['TheComments'];
      $headers  = 'MIME-Version: 1.0' . "\r\n";
       $headers .= 'Content-type: 
      text/html; charset=iso-8859-1' . "\r\n";
       $headers .= 'From: ' . 
      $EmailAddress . "\r\n";
       
       $message = '<table width="80%" 
      cellspacing="0" cellpadding="3" border="1" style="border-collapse:collapse; 
      border:1px solid #86BFE8" bordercolor="#86BFE8" 
      align="center">
           <tr>
            <td align="left" 
      colspan="2"><b>Visitor 
      Details:</b></td>
           </tr>
           <tr>
            <td 
      align="left" 
      colspan="2"> </td>
           </tr>
           <tr>
            <td 
      align="left" colspan="2"><b>Yes! I would like to receive information on 
      the following Delta 
      Products...</b></td>
           </tr>
           <tr>
            <td 
      align="left" 
      colspan="2"> </td>
           </tr>';
       if($all_mailouts 
      !='' || $brochures !='' || $emails_updates_promotions !=''){    
         $message 
      .=  '<tr>
              <td align="left" colspan="2"><b>Please 
      send 
      me:</b></td>
             </tr>';
           }
         if($all_mailouts 
      !=''){    
         $message .=  '<tr>
              <td 
      align="left"> </td>
              <td 
      align="left">'.$all_mailouts.'</td>
             </tr>';    
           }
         if($brochures 
      !=''){    
         $message .=  '<tr>
              <td 
      align="left"> </td>
              <td 
      align="left">'.$brochures.'</td>
             </tr>';    
           }
         if($emails_updates_promotions 
      !=''){    
         $message .=  '<tr>
              <td 
      align="left"> </td>
              <td 
      align="left">'.$emails_updates_promotions.'</td>
             </tr>';    
           }
         $message 
      .=  '<tr>
              <td align="left" 
      colspan="2"> </td>
             </tr>';       
       
       if($safety 
      !='' || $hoists !=''){    
         $message .=  '<tr>
              <td 
      align="left" colspan="2"><b>I am interested in the following product 
      lines:</b></td>
             </tr>';
           }
         if($safety 
      !=''){    
         $message .=  '<tr>
              <td 
      align="left"> </td>
              <td 
      align="left">'.$safety.'</td>
             </tr>';    
           }
         if($hoists 
      !=''){    
         $message .=  '<tr>
              <td 
      align="left"> </td>
              <td 
      align="left">'.$hoists.'</td>
             </tr>';    
           }
         $message 
      .=  '<tr>
              <td align="left" 
      colspan="2"> </td>
             </tr>';       
       $message 
      .=  '<tr>
            <td align="left"><b>Type of 
      User:</b></td>
            <td 
      align="left">'.$TypeofUser.'</td>
           </tr>
            
      <tr>
            <td align="left" 
      colspan="2"> </td>
            
           </tr>
            
      <tr>
            <td align="left"><b>First 
      Name:</b></td>
            <td 
      align="left">'.$FirstName.'</td>
           </tr>
           <tr>
            <td 
      align="left"><b>Last Name:</b></td>
            <td 
      align="left">'.$LastName.'</td>
           </tr>';
       if($CompanyName 
      !=''){    
        $message .='<tr>
            <td 
      align="left"><b>Company Name:</b></td>
            <td 
      align="left">'.$CompanyName.'</td>
           </tr>';
          }
           
       $message 
      .=    '<tr>
            <td align="left"><b>Street 
      Address:</b></td>
            <td 
      align="left">'.$StreetAddress.'</td>
           </tr>
           <tr>
            <td 
      align="left"><b>City:</b></td>
            <td 
      align="left">'.$City.'</td>
           </tr>
           <tr>
            <td 
      align="left"><b>Province State:</b></td>
            <td 
      align="left">'.$ProvinceState.'</td>
           </tr>
           <tr>
            <td 
      align="left"><b>Postal/Zip Code:</b></td>
            <td 
      align="left">'.$PostalZipCode.'</td>
           </tr>
           <tr>
            <td 
      align="left"><b>Telephone Number:</b></td>
            <td 
      align="left">'.$TelephoneNumber.'</td>
           </tr>';
       if($FaxNumber 
      !=''){
        $message .=    '<tr>
             <td 
      align="left"><b>Fax Number:</b></td>
             <td 
      align="left">'.$FaxNumber.'</td>
            </tr>';
       }
           
           
       $message 
      .=    '<tr>
            <td align="left"><b>Email 
      Address:</b></td>
            <td 
      align="left">'.$EmailAddress.'</td>
           </tr>';
       if($TheComments !=''){
         $message 
      .= '<tr>
             <td align="left" 
      colspan="2"><b>Comments:</b></td>
            </tr>
            <tr>
             <td 
      align="left" 
      colspan="2">'.$TheComments.'</td>
            </tr>';
        }   
         
       $message 
      .='</table>';
      $send=mail($to, $subject, $message, 
      $headers);
      if($sent) {
       header('Location: http://deltaindustries.ca/Web20%Pages/thank_you.html'); 
      //Redirect customer to thank_you page
      } else {
       echo 'Problem sending 
      mail';
      }
      ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 
      Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html 
      xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta 
      http-equiv="Content-Type" content="text/html; charset=utf-8" 
      />
      <title>Mail Script</title>
      </head>
      <body>
      </body>
      </html>