Jump to content

PHP formmailer doesn't work on different computers


jewelsmac6

Recommended Posts

Good morning,

 

I am writing for some help with a PHP formmailer script I found online. It works great when I fill out the form and upload a file from my PC laptop (Windows 7). The email is successful sent with the uploaded file from the form attached to the email. But, when my client tried to do the same thing (fill out the form as a test) from his PC and when I tried it from my MAC (OS X) the email never came through. Any help as to why this script only works on my PC laptop is very appreciated! I need this form to work on any computer in any browser. Thank you all!!

 

<?PHP
/*
    Contact Form from HTML Form Guide
    This program is free software published under the
    terms of the GNU Lesser General Public License.
    See this page for more info:
    http://www.html-form-guide.com/contact-form/contact-form-attachment.html
*/
require_once("./include/fgcontactform.php");
require_once("./include/captcha-creator.php");

$formproc = new FGContactForm();
$captcha = new FGCaptchaCreator('scaptcha');

$formproc->EnableCaptcha($captcha);

//1. Add your email address here.
//You can add more than one receipients.
$formproc->AddRecipient('sales@dependableprint.com'); //<<---Put your email address here


//2. For better security. Get a random tring from this link: http://tinyurl.com/randstr
// and put it here
$formproc->SetFormRandomKey('E6bZFICMgOhOnxI');

$formproc->AddFileUploadField('photo','jpg,jpeg,gif,png,bmp',2024);

if(isset($_POST['submitted']))
{
   if($formproc->ProcessForm())
   {
        $formproc->RedirectToURL("thank-you.php");
   }
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
      <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
      <title>Order Form</title>
      <link rel="STYLESHEET" type="text/css" href="contact.css" />
      <script type='text/javascript' src='scripts/gen_validatorv31.js'></script>
      <script type='text/javascript' src='scripts/fg_captcha_validator.js'></script>
</head>
<body>

<!-- Form Code Start -->
<form id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' enctype="multipart/form-data" accept-charset='UTF-8'>

<fieldset >
<legend>Please Fill in the Details Below</legend>

<input type='hidden' name='submitted' id='submitted' value='1'/>
<input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
<input type='text'  class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' />

<div class='short_explanation'>* required fields</div>

<div><span class='error'><?php echo $formproc->GetErrorMessage(); ?></span></div>

<div class='fieldContainer'>
    <span class="formText"><label for='name' >Your Full Name*: </label></span><br/>
    <input name='name' type='text' id='name' value='<?php echo $formproc->SafeDisplay('name') ?>' size="65" maxlength="50" /><br/>
    <span id='contactus_name_errorloc' class='error'></span>
</div>

<div class='fieldContainer'>
    <label for='bizName' >Business Name*: </label><br/>
    <input name='bizName' type='text' id='bizName' value='<?php echo $formproc->SafeDisplay('bizName') ?>' size="65" maxlength="50" /><br/>
    <span id='contactus_bizName_errorloc' class='error'></span>
</div>

<div style="width:700px; height:55px; padding:0; margin-top:8px; margin-bottom: 10px;">

<div style="width:235px; height:50px; float:left; padding:0;">
<span class="formText">Address*</span><br />
  <input name='address' type='text' id='address' value='<?php echo $formproc->SafeDisplay('address') ?>' size="25" maxlength="50" /><br />
    <span id='contactus_address_errorloc' class='error'></span></p>
</div>
    
    <div style="width:190px; height:50px; float:left; padding:0;">
<span class="formText">City*</span><br />
  <input name='city' type='text' id='city' value='<?php echo $formproc->SafeDisplay('city') ?>' size="25" maxlength="50" /><br />
    <span id='contactus_city_errorloc' class='error'></span></p>
    </div>
    
    <div style="width:100px; height:50px; text-align:center; float:left;">
<span class="formText">State*</span><br />
<input name='state' type='text' id='state' value='<?php echo $formproc->SafeDisplay('state') ?>' size="4" maxlength="2" /><br />
    <span id='contactus_state_errorloc' class='error'></span>
    </div>
    
    <div style="width:75px; height:50px; text-align:center; float:left;">
<span class="formText">Zipcode*</span><br />
<input name='zipcode' type='text' id='zipcode' value='<?php echo $formproc->SafeDisplay('zipcode') ?>' size="7" maxlength="5" /><br />
    <span id='contactus_zipcode_errorloc' class='error'></span>
    </div>
    
    </div>



<div class='fieldContainer'>
<div style="width:350px; float:left; ">
    <label for='email' >Email Address*:</label>
    <br />
<input name='email' type='text' id='email' value='<?php echo $formproc->SafeDisplay('email') ?>' size="50" /><br />
<span id='contactus_email_errorloc' class='error'></span>
</div>
    <div style="width:225px; float:left; ">
    <label for='phone' >Phone Number*:</label><br/>
    <input name='phone' type='text' id='phone' value='<?php echo $formproc->SafeDisplay('phone') ?>' size="15" maxlength="12" /> 
    <span class="fineprint">ex: 555-123-4567</span><br/>
    <span id='contactus_phone_errorloc' class='error'></span></div>
</div>

<p> </p>



<div id="tableRow0">

<div id="tableRow1">
<div id="tableRow1-1"><span class="formText">Letterhead</span></div>
  <div id="tableRow1-2"><label>
    <select name="letterhead" id="letterhead">
      <option value="None" selected="selected"></option>
<option value="70lb Bright White">70lb Bright White</option>
<option value="25% Cotton w/watermark">25% Cotton w/watermark</option>
<option value="Linen">Linen</option>
<option value="Laid">Laid</option>
<option value="30% recycled white">30% recycled white</option>
</select>
  </label></div>
<div id="tableRow1-3">
 </div>
<div id="tableRow1-4">
<label><span class="formText">QTY</span>
  <select name="letterheadQty" id="letterheadQty">
    <option value="0" selected="selected">0</option>
    <option value="500">500</option>
    <option value="1000">1000</option>
    <option value="1500">1500</option>
    <option value="2000">2000</option>
    <option value="2500">2500</option>
  </select>
  </label>
</div>
<div class="clear"></div>
</div>

<div class="clear"></div>

<div id="tableRow1">
<div id="tableRow1-1">
<span class="formText">Envelopes</span></div>
<div id="tableRow1-2">
<label>
  <select name="envelopes" id="envelopes">
    <option value="None" selected="selected"></option>
    <option value="#10 White Business">#10 White Business</option>
    <option value="#9 Return">#9 Return Env</option>
    <option value="6 3/4 white sm">6 3/4 white sm</option>
    <option value="#10 Window">#10 Window </option>
    <option value="#10 Security">#10 Security</option>
    <option value="#10 Peal & Seal">#10 Peal & Seal</option>
    <option value="#10 Peal & Seal Security">#10 Peal & Seal Security</option>
    <option value="#10 Linen or Laid">#10 Linen or Laid</option>
    <option value="#10 25% cotton watermarked">#10 25% cotton watermarked</option>
    <option value="6x9 White Catalog">6x9 White Catalog</option>
    <option value="6x9 Brown Catalog">6x9 Brown Catalog</option>
    <option value="6x9 White Brochure">6x9 White Brochure</option>
    <option value="9x12 White Catalog">9x12 White Catalog</option>
    <option value="9x12 White Brochure">9x12 White Brochure</option>
    <option value="10x13 White Catalog">10x13 White Catalog</option>
    <option value="10x13 White Brochure">10x13 White Brochure</option>
    <option value="10x15 White Catalog">10x15 White Catalog</option>
    <option value="10x15 White Brochure">10x15 White Brochure</option>
</select>
  </label>
</div>
  <div id="tableRow1-3">
   </div>
  <div id="tableRow1-4">
  <label><span class="formText">QTY</span>
  <select name="envelopesQty" id="envelopesQty">
    <option value="0" selected="selected">0</option>
    <option value="500">500</option>
    <option value="1000">1000</option>
    <option value="1500">1500</option>
    <option value="2000">2000</option>
    <option value="2500">2500</option>
  </select>
  </label>
  </div>
</div>

<div class="clear"></div>

<div id="tableRow1">
<div id="tableRow1-1">
<span class="formText">Business Cards</span></div>
<div id="tableRow1-2">
<label>
  <select name="businessCards" id="businessCards">
    <option value="None" selected="selected"></option>
    <option value="Std 80lb White Card Black Ink">Std 80lb White Card Black ink</option>
    <option value="Std 80lb White Card 1 color ink">Std 80lb White Card 1 Color ink</option>
    <option value="Std 80lb White Card Full Color">Std 80lb White Card Full Color</option>
    <option value="14pt Full color Glossy photo card">14pt Full color Glossy Photo card</option>
</select>
  </label>
</div>
  <div id="tableRow1-3"> </div>
  <div id="tableRow1-4">
  <label><span class="formText">QTY</span>
  <select name="businessCardsQty" id="businessCardsQty">
    <option value="0" selected="selected">0</option>
    <option value="250">250</option>
    <option value="500">500</option>
    <option value="1000">1000</option>
  </select>
  </label></div>

</div>

<div class="clear"></div>

<div id="tableRow1">
<div id="tableRow1-1">
<span class="formText">Carbonless</span>
</div>
<div id="tableRow1-2">
<label>
      <select name="carbonless" id="carbonless">
        <option value="None" selected="selected"></option>
    <option value="2 Part">2 Part</option>
    <option value="3 Part">3 Part</option>
    <option value="4 Part">4 Part</option>
    <option value="5 Part">5 Part</option>
</select>
  </label></div>
  <div id="tableRow1-3"> </div>
  <div id="tableRow1-4">
  <label><span class="formText">QTY</span>
  <select name="carbonlessQty" id="carbonlessQty">
    <option value="0" selected="selected">0</option>
    <option value="250 Sets">250 Sets</option>
    <option value="500 Sets">500 Sets</option>
    <option value="1000 Sets">1000 Sets</option>
  </select>
  </label>
  </div>
</div>

<div class="clear"></div>

<div id="tableRow1">
<div id="tableRow1-1"><span class="formText">Copies</span></div>
<div id="tableRow1-2">
<label>
      <select name="copies" id="copies">
        <option value="None" selected="selected"></option>
    <option value="1 Side B&W">1 side B&W</option>
    <option value="2 sides B&W">2 sides B&W</option>
    <option value="1 side color">1 side color</option>
    <option value="2 sides color">2 sides color</option>
</select>
  </label>
</div>
<div id="tableRow1-3">
 </div>
<div id="tableRow1-4">
<label><span class="formText">QTY</span>
  <select name="copiesQty" id="copiesQty">
    <option value="0" selected="selected">0</option>
    <option value="250">250</option>
    <option value="500">500</option>
    <option value="1000">1000</option>
    <option value="1500">1500</option>
    <option value="2000">2000</option>
    <option value="2500">2500</option>
    <option value="5000">5000</option>
  </select>
  </label></div>
  </div>

<div class="clear"></div>

<div id="tableRow1">
<div id="tableRow1-1"><span class="formText">Postcards</span></div>
<div id="tableRow1-2">
<label>
      <select name="postcards" id="postcards">
        <option value="None" selected="selected"></option>
    <option value="80lb White-Blk ink 4x6 1 side">80lb White-Blk ink 4x6 1 side</option>
    <option value="80lb White-Blk ink 4x6 2 sides">80lb White -Blk ink 4x6 2 sides</option>
    <option value="14pt Full color 2 sides 4x6">14pt Full Color 2 sides 4x6</option>
    <option value="other size">other size</option>
</select>
  </label></div>
  <div id="tableRow1-3"> </div>
  <div id="tableRow1-4">
  <label><span class="formText">QTY</span>
  <select name="postcardsQty" id="postcardsQty">
    <option value="0" selected="selected">0</option>
    <option value="250">250</option>
    <option value="500">500</option>
    <option value="1000">1000</option>
    <option value="2500">2500</option>
    <option value="5000">5000</option>
  </select>
  </label>
  </div>
</div>

</div><!-- end tableRow0 -->


<p> </p>
<p> </p>

<div class='container'>
<label for='message'><span class="formText">Please include any comments or special instructions we should know about:</span></label><br/>
    <span id='contactus_message_errorloc' class='error'></span>
    <span class="alignCenter"><textarea rows="5" cols="100" name='message' id='message'><?php echo $formproc->SafeDisplay('message') ?></textarea></span>
</div>

<div style="width:600px; height:60px; text-align:center">
<label for='photo' >Attach Your Art File:</label><br/>
    <input type="file" name='photo' id='photo' /><br/>
    <span id='contactus_photo_errorloc' class='error'></span>
</div>


<div class='container'>
    <div align="center"><img alt='Captcha image' src='show-captcha.php?rand=1' id='scaptcha_img' /></div>
    <div style="text-align:center"><label for='scaptcha' >Enter the code above here:</label>
    <span class="alignCenter"><input type='text' name='scaptcha' id='scaptcha' maxlength="10" /></span><br/>
    <span class="alignCenter"><span id='contactus_scaptcha_errorloc' class='error'></span></span></div>
    
    <div class='short_explanation'>Can't read the image?
    <a href='javascript: refresh_captcha_img();'>Click here to refresh</a>.</div>
</div>


<div class='container'>
<p style="text-align:center"><input type='submit' name='Submit' value='Submit' /></p>
</div>

</fieldset>
</form>
<!-- client-side Form Validations:
Uses the excellent form validation script from JavaScript-coder.com-->

<script type='text/javascript'>
// <![CDATA[

    var frmvalidator  = new Validator("contactus");
    frmvalidator.EnableOnPageErrorDisplay();
    frmvalidator.EnableMsgsTogether();
    frmvalidator.addValidation("name","req","Please provide your name");

frmvalidator.addValidation("bizName","req","Please provide your business's name.");

    frmvalidator.addValidation("email","req","Please provide your email address");

    frmvalidator.addValidation("phone","req","Please provide a contact number.");

frmvalidator.addValidation("address","req","Please provide your shipping address.");

frmvalidator.addValidation("city","req","Please provide your city.");

frmvalidator.addValidation("state","req","Please fill in.");

frmvalidator.addValidation("zipcode","req","Please fill in.");

    frmvalidator.addValidation("message","maxlen=2048","The exceeds the maximum limit. Please go back and shorten, then submit again. Thank you!");

    frmvalidator.addValidation("photo","file_extn=jpg;jpeg;gif;png;bmp;tif;tiff;eps;ai;pdf;ppt;pptx;doc;docx;","File format is not supported. Please upload one of the following formats: jpg, jpeg, gif, png, bmp, tiff, tiff, eps, ai, pdf, ppt, pptx, doc, docx.");

    frmvalidator.addValidation("scaptcha","req","Please enter the code in the image above");

    document.forms['contactus'].scaptcha.validator
      = new FG_CaptchaValidator(document.forms['contactus'].scaptcha,
                    document.images['scaptcha_img']);

    function SCaptcha_Validate()
    {
        return document.forms['contactus'].scaptcha.validator.validate();
    }

    frmvalidator.setAddnlValidationFunction("SCaptcha_Validate");

    function refresh_captcha_img()
    {
        var img = document.images['scaptcha_img'];
        img.src = img.src.substring(0,img.src.lastIndexOf("?")) + "?rand="+Math.random()*1000;
    }

// ]]>
</script>


</body>
</html>

Link to comment
Share on other sites

The form does seem to be working correctly. If I don;t fill in a required field or the security image is incorrect, it does give me the errors and then I go back to fill them in and it submits correctly. The form redirects to the thank-you.php page BUT doesn't always send the email. When on my MAC and my client's PC, the form does redirect to the thank-you.php even though it doesn't actually send the email. But when I fill out the form from my PC laptop on FF and IE it does send the email just fine. Any ideas? Thank you!!

Link to comment
Share on other sites

Yes, the files for the form are hosted in a folder on a Go Daddy hosted server. The OS/Hosting Type is: Linux / Shared Hosting. Hosting configuration: 2.1. PHP Version: 5.2. Bandwidth: unlimited. Does this help? Does it have anything to do with the POST method? There's a hidden note in the code saying there is a bug with IE, but it sent the email successfully for me using IE and FF on my laptop.

Link to comment
Share on other sites

For the time being, comment out this

if(isset($_POST['submitted']))

 

and replace it with this and see if that makes a difference

if( strtolower($_SERVER['REQUEST_METHOD']) === 'post' )

 

Also, GoDaddy's shared servers typically queue outgoing mail and send it every 15(?) minutes or so.

Link to comment
Share on other sites

Thank you for the tip! I replaced the code, and submitted the form from my MAC using Safari and Firefox. I clicked on the "check email" button several times to try and pull in any messages hanging out there, but nothing arrived. Is this script just useless? Do you know of any formmailer scripts with a file attachment field(s) that will work successfully on any computer or operating system?

Link to comment
Share on other sites

Internally the script is using the phpmailer class and the only way that the redirect to the thank-you.php will occur is if the mailer->Send() method returns a true. That implies that there is a sending mail server, the php script was able to connect to it, and it accepted the mail to send without returning any errors.

 

That would suggest that something that is submitted in the fields or as the file attachment is causing the problem, either on the sending mail server or at the receiving mail server.

 

When you try this on the different computers, are you entering the same exact information in the form fields and using the same file attachment?

 

Is your sales@dependableprint.com email address hosted on the same mail server as where the web page/this php script is running, i.e. is the sending mail server (at your web host) the same as the receiving mail server?

 

 

Link to comment
Share on other sites

I see, that makes sense now. Yes, the email account is also hosted by Go Daddy, so I know it's a legitimate paid for email service that is able to accept webforms (as it has been). The "class.phpmailer.php" file code is here: http://dependableprint.com/order/include/class.phpmailer.php_code.txt

 

Starting at 1745 is a list of mime types and I see within the list the below. Does this mean anything, since my hosting server at Go Daddy is PHP 5.2?

 

      'php'   =>  'application/x-httpd-php',
      'php3'  =>  'application/x-httpd-php',
      'php4'  =>  'application/x-httpd-php',
      'phps'  =>  'application/x-httpd-php-source',
      'phtml' =>  'application/x-httpd-php',

 

[attachment deleted by admin]

Link to comment
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.