Jump to content

Adding attachments to this email


dc_jt

Recommended Posts

Hi

Ive got an email working, all i need to do is attach the photo to the image. I have tried reading PHPMailer, Mime and all them but dont know how to integrate them into this, im really struggling.

Anyone five me an idea or tell me a tutorial which is easy to understand and is similar to the below:

Thanks a lot

[quote]<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/config.inc.php');
require_once(LOCAL_CLASSES.'/Tables/RCLTblReaders.class.php');
require_once(GLOBALS.'global_fns.php');



$oTblReaders = new RCLTblReaders();

if($_REQUEST[mode]=="apply"){
//error checking here

if(!$_REQUEST['name']){$_REQUEST[errors]['Name']='<div class="errors">Please enter your Name</div>';}
if(!$_REQUEST['address1']){$_REQUEST[errors]['Address']='<div class="errors">Please enter your Address</div>';}
if(!$_REQUEST['town']){$_REQUEST[errors]['Town']='<div class="errors">Please enter your Town</div>';}
if(!$_REQUEST['city']){$_REQUEST[errors]['City']='<div class="errors">Please enter your City</div>';}
if(!$_REQUEST['postcode']){$_REQUEST[errors]['Postcode']='<div class="errors">Please enter your Postcode</div>';}
if(!$_REQUEST['country']){$_REQUEST[errors]['Country']='<div class="errors">Please enter your Country</div>';}
if(!$_REQUEST['license']){$_REQUEST[errors]['License']='<div class="errors">Please agree to grant a license for the use of your text/photo</div>';}
if(!$_REQUEST['memory'] && $_FILES['photo']['error'] != UPLOAD_ERR_OK){$_REQUEST[errors]['Optional']='<div class="errors">Please enter either a photo or a memory</div>';}

if(validateemail($_REQUEST['email'])===false){$_REQUEST[errors]['Email']='<div class="errors">Please enter a valid Email address</div>';}


$sEmail = $_REQUEST['email'];
$iDuplicate = $oTblReaders->DuplicateEmail($sEmail);

if(sizeof($_REQUEST['errors'])<1)
{
//if no errors then execute.


if(isset($_FILES['photo']))
{
if($_FILES['photo']['error'] != UPLOAD_ERR_OK)
{
print("WARNING: You have not submitted a photo <br />");
}
else{
$sFileName = $_FILES['photo']['name'];
move_uploaded_file($_FILES['photo']['tmp_name'], $_SERVER['DOCUMENT_ROOT'].'/uploads'.$sFileName);
echo "Name: ".$_FILES['photo']['name']."<br />";
        echo "Size: ".$_FILES['photo']['size']."<br />";
        echo "Type: ".$_FILES['photo']['type']."<br />";
        echo "Photo Uploaded....<br />";

}
}

  if($iDuplicate != 0)
{
echo 'please choose a different email this one is already stored in the database';
}
else{
$oTblReaders->AddReader($_POST, $sFileName);
$_REQUEST['mode']="complete";
    }

//send email
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$address=$_REQUEST['address1'];
$town=$_REQUEST['town'];
$city=$_REQUEST['city'];
$postcode=$_REQUEST['postcode'];
$country=$_REQUEST['country'];
$license=$_REQUEST['license'];
$memory=$_REQUEST['memory'];
$photo=$_REQUEST['photo'];
$datap=$_REQUEST['datap'];

$to      = "liverpool@liverpooltest.com";
$subject = "Readers Archive";
$message = 'Name: ' .$name."\n". 'Email: '.$email."\n". 'Address: '.$address."\n". 'Town: '.$town."\n". 'City: '.$city."\n".'Postcode:'.$postcode."\n".'Country: '.$country."\n".'Photo:'.$photo;

$from =  'From: website@liverpooltest.com';
mail($to, $subject, $message, $from);
mail("***********", $subject, $message, $from);


}
}
?>

<?php
if ($_REQUEST['mode'] == 'complete')
{
echo '<div class="complete">Thank You for submitting your details.</div>';

}
else
{
?>

<? if($_REQUEST[errors]){
?>

<ul>
<?
foreach($_REQUEST[errors] as $error){echo $error;}
?></ul><?
}
?>

<form enctype="multipart/form-data" action="<?=$_SERVER['PHP_SELF']?>" method="post">
</center><BLOCKQUOTE><center><P><TABLE BORDER=0 CELLSPACING=0>
<TR>
<TD WIDTH=116>
<H4>Name:</H4>
</TD><TD>
<H4><input name="name" type="text" value="<?=htmlentities(stripslashes($_POST['name']))?>" SIZE=50/>
<br class="clear"/></H4>
</TD></TR>
<TR>
<TD WIDTH=116>
<H4>Address:</H4>
</TD><TD>
<H4><input name="address1" type="text" value="<?=htmlentities(stripslashes($_POST['address1']))?>" SIZE=50/>
<br class="clear"/>
</TD></TR>
<TR>
<TD WIDTH=116>
<H4>Town:</H4>
</TD><TD>
<H4><input name="town" type="text" value="<?=htmlentities(stripslashes($_POST['town']))?>" SIZE=50/>
<br class="clear"/>
</TD></TR>
<TR>
<TD WIDTH=116>
<H4>City:</H4>
</TD><TD>
<H4><input name="city" type="text" value="<?=htmlentities(stripslashes($_POST['city']))?>" SIZE=50/>
<br class="clear"/>
</TD></TR>
<TR>
<TD WIDTH=116>
<H4>Post Code/Zip Code:</H4>
</TD><TD>
<H4><input name="postcode" type="text" value="<?=htmlentities(stripslashes($_POST['postcode']))?>"/></H4>
<br class="clear"/>
</TD></TR>
<TR>
<TD WIDTH=116>
<H4>Country:</H4>
</TD><TD>
<H4>
<select name="country">
        <option value="United Kingdom">United Kingdom</option>
        <option value="United States of America">United States of America</option>
        <option value="Spain">Spain</option>
        <option value="Italy">Italy</option>
      </select>
<TR>
<TD WIDTH=116>
<H4>Email Address:</H4>
</TD><TD>
<H4><input name="email" type="text" value="<?=htmlentities(stripslashes($_POST['email']))?>" SIZE=50/>
<br class="clear"/></H4>
</TD></TR>
<TR>
<TD WIDTH=210>
<H4>I agree to grant a license for you to use my text/photograph</H4>
</TD><TD>
<H4><input name="license" type="checkbox" id="license" value="1" <?=($_POST['license'] == '1')?' checked="checked"':''?>/></H4>
<TR>
<TD WIDTH=116>
<H4>Photo:</H4>
</TD><TD>
<H4><input type="file" name="photo" ></H4>
<br class="clear"/></H4>
</TD></TR>
<TR>
<TD WIDTH=116>
<H4>Memory:</H4>
</TD><TD>
<H4><textarea name="memory" rows=6 cols=40 id="memory"><?=($_POST['memory'])?></textarea></textarea></H4>
</TD></TR>
<TR>
<TD WIDTH=210>
<H4>Data Protection:</H4>
</TD><TD>
<H4><input name="datap" type="checkbox" id="datap" value="1" <?=($_POST['datap'] == '1')?' checked="checked"':''?>/></H4>


<br class="clear"/>
<input type="Submit" name="submit" value="Submit"  class="button"/>
  <input type="hidden" name="mode" value="apply" />
<?php }//end else?>[/quote]
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.