Jump to content

[SOLVED] Why wont this simple mailer work??? Urgent help please


T2theC

Recommended Posts

Hi guys, thanks for taking a look and helping me out.

 

I am using a from to email using this script. I have used a similar setup many times before for a variety of websites. For some reason I cannot get it to work. I haven't changed anything except the VARs and email address.

 

I hope you can help. Thanks.

 

<?php
  $firstname = strip_tags ($_REQUEST['firstname']);
  $surname = strip_tags ($_REQUEST['surname']);
  $position = strip_tags ($_REQUEST['position']);
  $compname = strip_tags ($_REQUEST['compname']);
  $email = strip_tags ($_REQUEST['email']);
  $phone = strip_tags ($_REQUEST['phone']);
  $address = strip_tags ($_REQUEST['address']);
  $postcode = strip_tags ($_REQUEST['postcode']);
  $comptype = strip_tags ($_REQUEST['comptype']);
  $area = strip_tags ($_REQUEST['area']);
  $other = strip_tags ($_REQUEST['other']);
  $employees = strip_tags ($_REQUEST['employees']);
  $established = strip_tags ($_REQUEST['established']);
  $turnover = strip_tags ($_REQUEST['turnover']);
  $profit = strip_tags ($_REQUEST['profit']);
  $sector = strip_tags ($_REQUEST['sector']);
  $overview = strip_tags ($_REQUEST['overview']);
  $challenge = strip_tags ($_REQUEST['challenge']);
  $overcome = strip_tags ($_REQUEST['overcome']);
  $achieved = strip_tags ($_REQUEST['achieved']);
  $mentor = strip_tags ($_REQUEST['mentor']);
  $question = strip_tags ($_REQUEST['question']);
  $terms = strip_tags ($_REQUEST['terms']);
  $contact = strip_tags ($_REQUEST['contact']);
  $message ="
  NAME:         $firstname $surname
  
  POSITION:     $position
  COMPANY:      $compname
  
  EMAIL:        $email
  PHONE:        $phone
  
  ADDRESS:      $address
  POSTCODE:     $postcode
  
  $comptype
  
  $area
  $other

  $employees
  
  $established
  
  $turnover
  
  $profit
  
  $sector
  
  $overview
  
  $challenge
  
  $overcome
  
  $achieved
  
  $mentor
  
  $question
  
  $terms
  $contact";

  mail( "[email protected]", "Enquiry from Website", $message, "From: $email" );
header( "Location: http://www.MYADDRESS/thankyou.php" )
?>

For some reason I cannot get it to work.

 

What's not working? Assuming you just aren't getting the email...try something simpler first and build on it:

mail( "[email protected]", "Enquiry from Website", "Test Message" );

Hi Aaron,

 

Thanks for the speedy reply. I am really grateful for your help

 

Your right - I'm not getting mail.

 

I have just tried the simpler script and that works fine.

 

I have double and ripple checked everything. I'm sure it is something very simple. Why is it this always happens on deadline! Oh well.

 

Two things that I am doing differently are:

• Using SPRY for the first time to validate the form.

• Using JavaScript to count the number of words in the 'Questions' part of the form.

 

Here is the form I am posting from:

 

<form id="EntryForm" name="EntryForm" method="post" action="YIBC_Entry.php">
      <table width="487" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="181" valign="top" bgcolor="#B8EDFF"><p><strong>First Name:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p><span id="firstname1">
            <label>
              <input name="firstname" type="text" id="firstname" size="40" />
              <br />
            </label>
            <span class="textfieldRequiredMsg"><br />
          Please enter your first name</span><span class="textfieldMinCharsMsg">Please enter your first name.</span></span></p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>Surname:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p><span id="surname1">
            <label>
              <input name="surname" type="text" id="surname" size="40" />
            </label>
            <br />
            <span class="textfieldRequiredMsg">          Please enter your surname.<br />
          </span><span class="textfieldMinCharsMsg">Please enter your surname.</span></span></p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>Position:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p><span id="position1">
            <label>
              <input name="position" type="text" id="position" size="40" />
            </label>
            <span class="textfieldRequiredMsg">Please enter your job title.</span><span class="textfieldMinCharsMsg"></span></span><br />
          </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>Company Name:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p><span id="compname1">
            <label>
              <input name="compname" type="text" id="compname" size="40" />
            </label>
            <span class="textfieldRequiredMsg"><br />
              Please enter your companies name<br />
              </span><span class="textfieldMinCharsMsg"><br />
          Please enter your companies full name.</span></span></p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#C4ECFF"><p><strong>E-mail:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#C4ECFF"><p><span id="email1">
            <label>
              <input name="email" type="text" id="email" size="40" />
            </label>
            <span class="textfieldRequiredMsg"><br />
              Please enter your email address.</span><span class="textfieldInvalidFormatMsg"><br />
          Please enter your email address.</span></span></p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#C4ECFF"><p><strong>Telephone:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#C4ECFF"><p><span id="phone1">
            <label>
              <input name="phone" type="text" id="phone" size="40" />
            </label>
            <span class="textfieldRequiredMsg"><br />
          Please enter your phone number.</span><span class="textfieldMinCharsMsg"></span></span></p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#C4ECFF"><p><strong>Address:</strong></p></td>
          <td colspan="2" rowspan="3" valign="top" bgcolor="#C4ECFF"><p><span id="address1">
            <label>
              <textarea name="address" id="address" cols="35" rows="5"></textarea>
              <br />
            </label>
          <span class="textareaRequiredMsg">Please enter your address.</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span><span class="textareaMinCharsMsg">Minimum number of characters not met.</span></span></p></td>
        </tr>
        <tr valign="top">
          <td bgcolor="#C4ECFF"><p> </p></td>
        </tr>
        <tr valign="top">
          <td bgcolor="#C4ECFF"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#C4ECFF"><p><strong>Post Code:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#C4ECFF"><p><span id="postcode1">
            <label>
              <input name="postcode" type="text" id="postcode" size="40" />
            </label>
          <span class="textfieldRequiredMsg">Please enter your postcode.</span></span></p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>Legal Structure:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p>
            <label>
              <select name="comptype" id="comptype">
                <option selected="selected">----Please Select----</option>
                <option value="Community interest company">Community interest company</option>
                <option value="Cooperative">Cooperative</option>
                <option value="Partnership">Partnership</option>
                <option value="Limited liability partnership">Limited liability partnership</option>
                <option value="Limited partnership">Limited partnership</option>
                <option value="Ltd.">Ltd.</option>
                <option value="PLC">PLC</option>
                <option value="Sole trader">Sole trader</option>
                <option value="Unlimited company ">Unlimited company </option>
              </select>
            </label>
          </p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>What sector<br />
          are you in?</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p><span id="spryselect1"><span class="selectRequiredMsg">Please select an item.</span></span>
            <label>
              <select name="area" id="area">
                <option selected="selected">----Please Select----</option>
                <option value="Private Sector">Private Sector</option>
                <option value="Social Enterprise">Social Enterprise</option>
                <option value="Charity">Charity</option>
                <option value="Other">Other - Please give details</option>
              </select>
              <br />
              <em>
                <input name="other" type="text" id="other" value="If other, please specify." size="40" />
              </em> </label>
          </p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>No. of employees:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p>
            <label>
              <select name="employees" id="employees">
                <option selected="selected">----Please Select----</option>
                <option value="1-5">1-5</option>
                <option value="6-10">6-10</option>
                <option value="11-20">11-20</option>
                <option value="21-50">21-50</option>
                <option value="51-250">51-250</option>
                <option value="250+">250+</option>
              </select>
            </label>
          </p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#C4ECFF"><p><strong>When was the company established?</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#C4ECFF"><p><span id="established1">
            <label>
              <input name="established" type="text" id="established" size="40" />
            </label>
            <span class="textfieldRequiredMsg"><br />
              Please tell us when your business was established.</span><span class="textfieldMinCharsMsg"><br />
          Please tell us when your business was established.</span></span></p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#CDEBFF"><p><strong>Turnover:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#CDEBFF"><p><span id="tunover1">
            <label>
              <input name="turnover" type="text" id="turnover" size="40" />
            </label>
          <span class="textfieldRequiredMsg">Please tell us last years turnover.</span><span class="textfieldMinCharsMsg">Please tell us last years turnover.</span></span></p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>Profit last year:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p>
            <label>
              <select name="profit" id="profit">
                <option selected="selected">----Please Select----</option>
                <option value="£0k-50k">£0k-50k</option>
                <option value="£50k-£200k">£50k-£200k</option>
                <option value="£200k-£500k">£200k-£500k</option>
                <option value="£500k-£1m">£500k-£1m</option>
                <option value="£1m-£2m">£1m-£2m</option>
                <option value="£2m-£3m">£2m-£3m</option>
                <option value="£3m-£4m">£3m-£4m</option>
                <option value="£5m+">£5m+</option>
              </select>
            </label>
          </p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>Sector:</strong></p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p><span id="sector1">
            <label>
              <input name="sector" type="text" id="sector" size="40" />
            </label>
            <span class="textfieldRequiredMsg">Please tell us what sector you are in.</span><span class="textfieldMinCharsMsg"><br />
          Please tell us what sector you are in.</span></span></p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>Provide some background information and an overview of your organisation:
            </strong><br />
          (max 200 words)</p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p>
            <label>
              <textarea name="overview" id="overview" cols="40" rows="8"></textarea>
              
              <input type=button value="Count Words" OnClick ="CountWords(this.form.overview, true, true);">
            </label>
          </p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>Give details of the challenge or opportunity that you faced?</strong><br />
            (max 200 words)</p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p>
            <label>
              <textarea name="challenge" id="challenge" cols="40" rows="8"></textarea>
              <br>
              <input type=button value="Count Words" OnClick ="CountWords(this.form.challenge, true, true);">
            </label>
          </p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>Tell us what you have done to overcome the challenge or maximize the opportunity:</strong><br />
          (max 500 words)</p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p>
            <label>
              <textarea name="overcome" id="overcome" cols="40" rows="8"></textarea>
              <input type=button value="Count Words" OnClick ="CountWords(this.form.overcome, true, true);">
            </label>
          </p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>Provide details of<br />
            what has been achieved as a result:</strong><br />
          (max 200 words)</p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p>
            <label>
              <textarea name="achieved" id="achieved" cols="40" rows="8"></textarea>
              <input type=button value="Count Words" OnClick ="CountWords(this.form.achieved, true, true);">
            </label>
          </p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>Tell us what you want a business mentor?</strong><br />
          (max 200 words)</p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p><label>
            <textarea name="mentor" id="mentor" cols="40" rows="8"></textarea>
              <input type=button value="Count Words" OnClick ="CountWords(this.form.mentor, true, true);">            
              </label>
          </p></td>
        </tr>
        <tr>
          <td valign="top"></td>
          <td colspan="2" valign="top"><p> </p></td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#B8EDFF"><p><strong>What question would you as a business mentor?<br />
          </strong>(max 50 words)</p></td>
          <td colspan="2" valign="top" bgcolor="#B8EDFF"><p>
            <label>
              <textarea name="question" id="question" cols="40" rows="8"></textarea>
              <input type=button value="Count Words" OnClick ="CountWords(this.form.question, true, true);">
            </label>
          </p></td>
        </tr>
        <tr>
          <td valign="middle"> </td>
          <td colspan="2"> </td>
        </tr>
        <tr>
          <td colspan="3" valign="middle" bgcolor="#B8EDFF"><p><strong>I confirm I have read and accept the terms and conditions</strong> <span id="terms1">
            <label>
              <input name="terms" type="checkbox" id="terms" value="Yes" />
            </label>
            <span class="checkboxRequiredMsg"><br />
            You must agree to the terms and conditions.</span></span><br />
          </p></td>
        </tr>
        <tr>
          <td colspan="3" valign="middle" bgcolor="#B8EDFF"><p>I am happy for Business Link to contact me
            :
            <label>
              <input name="contact" type="radio" id="Contact_0" value="Yes" checked="checked" />
              Yes</label>
            
            <label>
              <input type="radio" name="Contact" value="No" id="Contact_1" />
              No</label>
            
          </p></td>
        </tr>
        <tr>
          <td valign="middle"><p> </p></td>
          <td width="221"> </td>
          <td width="85"><input type="submit" name="Submit" id="Submit" value="Submit" /></td>
        </tr>
      </table>
      <!-- end #mainContent -->
    </form>

headers? I think there are a few required headers that if you don't send them, the message will end up getting junked by spam filters. That may mean your ISP may be junking it even before it gets to you because it is missing the proper headers.

Test your script again but leave parameter 4 ('additional headers') empty so that PHP will use the default ones.

Thanks Brian,

 

I gave just tried:

mail( "[email protected]", "Enquiry from Website", $message, "From: $email", ' ' );

 

Using both ' ' and " " - Neither has worked.

 

As you may have guessed I am a noobie!

 

I know my server is set up ok as I have used many forms like this already. I'm stuck!!

Glad to hear its working for u... I don't have the time at the moment to look myself, but there is a list of headers that most ISP's will be looking for that if aren't present will flag as spam. Look on the great WWW that way you can use custom headers.

BTW, (again, not much time to look myself) I believe you can change/look at the default headers in the php.ini file being used.

If you don't know where to find that, use function php_info() and find out what ini is loaded up. Changes don't take place until server is restarted (at least true on IIS, I don't use Apache on regular basis)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.