Jump to content

Include image in PHP email form


justspiffy
 Share

Recommended Posts

Hi there,

 

I have created a simple php email form, which works just fine, but now I have been asked to include an image of the company logoat the top of the email the user receives. I am new to php, so my first thought was that I could just add a line that had the path to the image on the server like so: $mailimg = 'http://domain.ca/images/image.gif'; and then call it in the $message:

$headers = "From: $email\r\n\r\n";

$subject = "Cancellation Request Form from Website";

$message .= "$mailimg";

$message = "Notice Date: $ndate\r

Brokerage: $brokerage\r

 

but that doesnt seem to be working for me. I get the email message, but with no image attached. Any ideas on how I can simply do this. Again I am new to php, so the easier the better

 

Here is my code

<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $me = $_SERVER['PHP_SELF'];

?>
          <form name="form1" method="post"
         action="<?php echo $me;?>">
            <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td><img src="../images/dot_trans.gif" width="2" height="2" /><br />
        <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><img src="../images/dot_trans.gif" width="10" height="10" /><br />
          <table width="100%" height="183" border="0" align="center" cellpadding="3" cellspacing="3">
                <tr>
                  <td width="147"><strong>Notice Date</strong></td>
                  <td width="263"><span id="sprytextfield1">
                    <label>
                      <input name="ndate" type="text" id="ndate" size="40" />
                      </label>
                    <span class="textfieldRequiredMsg">Please Enter Notice Date.</span></span></td>
                  <td width="127"><strong>Broker Name</strong></td>
                  <td width="271"><span id="sprytextfield7">
                    <input name="brokername" type="text" id="brokername" size="40" />
                    <span class="textfieldRequiredMsg">Please Enter Broker Name.</span></span></td>
                </tr>
                <tr>
                  <td><strong>Brokerage</strong></td>
                  <td><span id="sprytextfield2">
                    <label>
                      <input name="brokerage" type="text" id="brokerage" size="40" />
                    </label>
                    <span class="textfieldRequiredMsg">Please Enter Brokerage</span></span></td>
                  <td><strong>Phone Number</strong></td>
                  <td><span id="sprytextfield8">
                    <input name="pnum" type="text" id="pnum" size="40" />
                    <span class="textfieldRequiredMsg">Please Enter A Phone Number.</span></span></td>
                  </tr>
                <tr>
                  <td><strong>RJFC Contract #</strong></td>
                  <td><span id="sprytextfield3">
                    <input name="rjfccon" type="text" id="rjfccon" size="40" />
                    <span class="textfieldRequiredMsg">Please Enter A Contact Number</span></span></td>
                  <td><strong>E Mail</strong></td>
                  <td><span id="sprytextfield9">
                  <input name="email" type="text" id="email" size="40" />
                  <span class="textfieldRequiredMsg">Please Enter A E Mail Address.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
                  </tr>
                <tr>
                  <td height="28"><strong>Insured</strong></td>
                  <td><span id="sprytextfield4">
                    <input name="insured" type="text" id="insured" size="40" />
                    <span class="textfieldRequiredMsg">Please Enter Name of Insured</span></span></td>
                  <td rowspan="3" valign="top"><strong>Reason for cancellation</strong></td>
                  <td rowspan="3"><label for="cancel"></label>
                    <span id="sprytextarea1">
                    <textarea name="cancel" id="cancel" cols="30" rows="5"></textarea>
                    <span class="textareaRequiredMsg">Please enter a reason for cancellation.</span></span></td>
                  </tr>
                <tr>
                  <td height="28"><strong>Policy #</strong></td>
                  <td><span id="sprytextfield5">
                    <input name="polnum" type="text" id="polnum" size="40" />
                    <span class="textfieldRequiredMsg">Please Enter A Policy Number.</span></span></td>
                  </tr>
                <tr>
                  <td height="22"> </td>
                  <td> </td>
                </tr>
                </table>
          <br />
          <br />
          <table width="822" align="center" cellpadding="0" cellspacing="0">
          
            <tr>
              <td width="569"><div align="left">RJFC will process the Cancellation Request    upon receipt.  All documents will be    sent to the    Insured by registered mail.  A fax or    e-mail copy of the documents will be sent to the Broker and Insurer.                </div>                <p> </p></td>
            </tr>
        </table>
          <table width="97%" border="0" align="center" cellpadding="3" cellspacing="3">
            <tr>
                    <td width="801"><div align="center">
                      <label>
                        <input name="Submit" type="submit" value="Submit" />
                        </label>
                      <label>
                        <input name="reset" type="reset" id="reset" value="Reset" />
                        </label>
                      </div></td>
                  </tr>
        </table>
           
            <img src="../images/dot_trans.gif" width="10" height="10" /></td>
        </tr>
      </table>
      
      <img src="../images/dot_trans.gif" width="2" height="2" /></td>
    </tr>
  </table>
</form>
<?php
} else {
error_reporting(0);
$recipient = 'contact@justspiffy.ca';
$ndate = stripslashes($_POST['ndate']);
$brokerage = stripslashes($_POST['brokerage']);
$rjfccon = stripslashes($_POST['rjfccon']);
$insured = stripslashes($_POST['insured']);
$polnum = stripslashes($_POST['polnum']);
$brokername = stripslashes($_POST['brokername']);
$pnum = stripslashes($_POST['pnum']);
$email = stripslashes($_POST['email']);
$cancel = stripslashes($_POST['cancel']);
$mailimg = 'http://rjfc.ca/new/images/quote.gif';

putenv ("QMAILUSER=contact");
putenv ("QMAILNAME=contact@justspiffy.ca");
putenv ("QMAILHOST=justspiffy.ca");

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: multipart/mixed;charset=us-ascii\r\n";
$headers .= "From: contact@justspiffy.ca";



$headers = "From: $email\r\n\r\n";
$subject = "Cancellation Request Form from Website";
$message .= "$mailimg";
$message = "Notice Date: $ndate\r
Brokerage: $brokerage\r
RJFC Contact Number: $rjfccon\r
Insured: $insured\r
Policy Number: $polnum\r
Broker Name: $brokername\r
Phone Number: $pnum\r
Email: $email\r
Reason for cancellation: $cancel\r


      "; 
      mail($recipient, $subject, $message, $headers);
      if (!mail) {
          echo "Message failed to send";
      } else {
          echo nl2br ("<center><br><br><br><br><br><br><br><br><br><br>Thank you.  Your request has been sent.  A representative from RJFC will contact you shortly.<br><br><br><br><br><br><br><br><br><br></center>");
      }
}
?>

Link to comment
Share on other sites

Sorry, I don't have an answer for the question. Have you tried searching for "php mail attachment"...there seems to be a few tuts on the subject:

http://www.google.com/search?q=php+mail+attachment

 

 

The main reason for responding was to caution you about using PHP_SELF as the form action. Here is why:

http://www.mc2design.com/blog/php_self-safe-alternatives

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

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