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 ,

 Answers

1
 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" 
      ."--".$uid."rn"
      ."Content-type:text/plain; charset=iso-8859-1rn"
      ."Content-Transfer-Encoding: 7bitrnrn"
      .$message."rnrn"
      ."--".$uid."rn"
      ."Content-Type: application/octet-stream; name="".$filename.""rn"
      ."Content-Transfer-Encoding: base64rn"
      ."Content-Disposition: attachment; filename="".$filename.""rnrn"
      .$content."rnrn"
      ."--".$uid."--"; 
  return mail($to, $subject, "", $header);
 }
Wednesday, August 17, 2022
 
5

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

include('Mail.php');
include('Mail/mime.php');

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

$mime = new Mail_mime();

$mime->setTXTBody($text);
$mime->setHTMLBody($html);

$mime->addAttachment($file,'application/octet-stream');

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

$mail =& Mail::factory('mail', $params);
$mail->send('mail@domain.pl', $hdrs, $body); 
Saturday, October 29, 2022
 
seb35
 
5

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 (pecl.php.net)

Options:
  ...
  -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
1

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
4

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 :