Viewed   78 times

How to send the email with resume attachment ,

i take snippet from this place Click here

In this site, snippet works fine,

Even i got the mail, but attachment is not working, am getting attment as noname with 0kb

size file, What is Issue in that snippet ,


 function mail_attachment($to, $subject, $message, $from, $file) {
  // $file should include path and filename
  $filename = basename($file);
  $file_size = filesize($file);
  $content = chunk_split(base64_encode(file_get_contents($file))); 
  $uid = md5(uniqid(time()));
  $from = str_replace(array("r", "n"), '', $from); // to prevent email injection
  $header = "From: ".$from."rn"
      ."MIME-Version: 1.0rn"
      ."Content-Type: multipart/mixed; boundary="".$uid.""rnrn"
      ."This is a multi-part message in MIME format.rn" 
      ."Content-type:text/plain; charset=iso-8859-1rn"
      ."Content-Transfer-Encoding: 7bitrnrn"
      ."Content-Type: application/octet-stream; name="".$filename.""rn"
      ."Content-Transfer-Encoding: base64rn"
      ."Content-Disposition: attachment; filename="".$filename.""rnrn"
  return mail($to, $subject, "", $header);
Wednesday, August 17, 2022

Found this code as one of the first hits of the google://pear mail attachment search.


$text = 'Text version of email';
$html = '<html><body>HTML version of email</body></html>';
$file = './files/';
$hdrs = array(
              'From'    => '',
              'To'      => '',
              'Subject' => 'Test mime message'

$mime = new Mail_mime();



$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$mail =& Mail::factory('mail', $params);
$mail->send('', $hdrs, $body); 
Saturday, October 29, 2022

Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):

$ pecl -d php_suffix=5.6 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.0 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.1 install <package>
$ pecl uninstall -r <package>

The -d php_suffix=<version> piece allows you to set config values at run time vs pre-setting them with pecl config-set. The uninstall -r bit does not actually uninstall it (from the docs):

vagrant@homestead:~$ pecl help uninstall
pecl uninstall [options] [channel/]<package> ...
Uninstalls one or more PEAR packages.  More than one package may be
specified at once.  Prefix with channel name to uninstall from a
channel not in your default channel (

  -r, --register-only
        do not remove files, only register the packages as not installed

The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).

Monday, December 12, 2022

You have already stored it when you accept the file-upload from PHP.

Simply use it when it is stored in the tmp folder.

PHP will automagically delete it for you when your script ends.

Thursday, October 6, 2022

Never used any of those, but they look interesting..

Take a look at Gearman as well.. more overhead in systems like these but you get other cool stuff :) Guess it depends on your needs ..

Friday, November 11, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :