Jump to content

Recommended Posts

Hi guys, im trying to send this email with attachment but it doesn't give me any error and it doesn't send any emails. I have echoed out send to address and have had added echo on every step to see where issue is but it passes everything and doesn't send anything. 

 

Can you please help, driving me nuts for last two days,


<?php 
if (isset($_POST['work'])){


$email=mysql_escape_string($_POST['email']);
$phone=mysql_real_escape_string($_POST['phone']);
$myaddress=mysql_real_escape_string($_POST['address_1']);
$city=mysql_real_escape_string($_POST['city']);
$zip=mysql_real_escape_string($_POST['zip']);
$country=mysql_real_escape_string($_POST['country']);
$covering=mysql_real_escape_string($_POST['covering']);
$signature=mysql_real_escape_string($_POST['signature']);
$upload_name=$_FILES["upload"]["name"];
$upload_type=$_FILES["upload"]["type"];
$upload_size=$_FILES["upload"]["size"];
$upload_temp=$_FILES["upload"]["tmp_name"];
$to='roozbeh.jalali@me.com';
$fp = fopen($upload_temp, "rb");

$file = fread($fp, $upload_size);
$file = chunk_split(base64_encode($file));
$num = md5(time());
$subject = 'Work wit us';
$message ="
<html>
<head>
<title>Jobs</title>
</head>
<body>
<p>Name: $signature</p>
<p>Email: $email</p>
<p>Phone: $phone</p>
<p>Address: $myaddress</p>
<p>City: $city</p>
<p>Zip: $zip</p>
<p>Country: $country</p>
<p>Covering Note: $covering</p>
</body>
</html>
";


       $headers  = "From: Work With us<".$email.">\r\n";
       $headers  .= "MIME-Version: 1.0\r\n";
       $headers  .= "Content-Type: multipart/mixed; ";
       $headers  .= "boundary=".$num."\r\n";
       $headers  .= "--$num\r\n";
       $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n";
       $headers .= "X-Mailer: PHP v".phpversion()."\r\n";
       $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
       $headers .= "Content-Transfer-Encoding: 8bit\r\n";
       $headers .= "".$message."\n";
       $headers .= "--".$num."\n";
       $headers  .= "Content-Type:".$upload_type." ";
       $headers  .= "name=\"".$upload_name."\"r\n";
       $headers  .= "Content-Transfer-Encoding: base64\r\n";
       $headers  .= "Content-Disposition: attachment; ";
       $headers  .= "filename=\"".$upload_name."\"\r\n\n";
       $headers  .= "".$file."\r\n";
       $headers  .= "--".$num."--";
       mail($to, $subject, $message, $headers);

     fclose($fp);

}
?>

<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" class="ddd" method="post" id="work" enctype="multipart/form-data">
<h1 class='titles-400'>Work with us</h1><br/>
<h2 class="subheader">Submit Your CV</h2>
      <div class="control-group">
    <label class="control-label" for="inputEmail">Full Name:</label>
    <div class="controls">
      <input type="text" class="validate[required] text-input" name="signature"/>
    </div>
</div>
 <div class="control-group">
    <label class="control-label" for="inputEmail">Email</label>
    <div class="controls">
      <input type="email" name="email" class="validate[required,custom[email]] text-input"/>
    </div>
  </div>
  
   
    <div class="control-group">
    <label class="control-label" for="inputEmail">Phone:</label>
    <div class="controls">
      <input type="text"  class="validate[required] text-input" name="phone"/>
    </div>
</div>


    <div class="control-group">
    <label class="control-label" for="inputEmail">Address:</label>
    <div class="controls">
      <input type="text"  name="address_1" class="validate[required] text-input" />
    </div>
</div>
  

  
      <div class="control-group">
    <label class="control-label" for="inputEmail">City:</label>
    <div class="controls">
      <input type="text"  class="validate[required] text-input" name="city"/>
    </div>
</div>
      
                  <div class="control-group">
    <label class="control-label" for="inputEmail">Zip / Postal Code:</label>
    <div class="controls">
      <input type="text"  class="validate[required] text-input" name="zip"/>
    </div>
</div>
  
      
      
            <div class="control-group">
    <label class="control-label" for="inputEmail">Country:</label>
    <div class="controls">
      <input type="text" class="validate[required] text-input" name="country"/>
    </div>
</div>

            <div class="control-group">
    <label class="control-label" for="inputEmail">Covering Note:</label>
    <div class="controls">
      <textarea class="validate[required] text-input span9" name="covering" rows="10"></textarea>
    </div>
</div>

   
        
  <div class="control-group">
<label class="control-label" for="inputEmail">Upload CV</label>
<div class="controls">
<input type="file" name="upload" id="file" class="validate[required]">
<span class="help-block">(Must be .doc, .docx, .pdf or .rtf and 1Mb or less)</span>
</div>


  <label class="control-label" for="how">How did you hear about us?</label>
    <div class="controls">
     <select name="how" class="validate[required]">
    <option value="">- Please Select -</option>
    <option value="YouTube">YouTube</option>
    <option value="Facebook">Facebook</option>
    <option value="Twitter">Twitter</option>
    <option value="Friends">Friends</option>
    <option value="Search Engine">Search Engine</option>
    <option value="Email Campaign">Email Campaign</option>
    <option value="Other">Other</option>
</select>
    </div>
  </div>

  <div class="control-group"> 
    <div class="controls">

      <button type="submit"  class="btn btn-custom" name="work">Submit</button>
    </div>
  </div>

</form>

Thank you all in advance

Link to comment
https://forums.phpfreaks.com/topic/279738-php-mail/
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.