Announcement

Collapse
No announcement yet.

Sintax to use to write $mail_attachments with multiple files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sintax to use to write $mail_attachments with multiple files

    Hi,
    I'm using sc_mail_send and one of variable to insert is $mail_attachment ..
    For one file it's easy and it works.
    When you got more than one file which is the right sintax to use ???

    'file01.xxx , file02.yyy , file03.zzz' I did a try but it doesn't work

    'file01.xxx ; file02.yyy ; file03.zzz' ???

    'file01.xxx' , 'file02.yyy' , 'file03.zzz' I don't think it's good because they are read as parameters.....

    I DON'T KNOW...... ;-(


  • #2
    Hi Giovanni
    try to use an array as attachments
    Let me know if this solve your problem
    Giorgio Bravi
    Dolphin Software & Thinkware
    giorgio.bravi@dolphin.it

    Comment


    • #3
      Hello Giorgio ,
      after struggling hours I found a kind of workaround because send mail works only with one file... no way . There are other libraries like phpmailer or Mandrill but for me it's enough the standard ;-)
      The workaround was writing first files in server directory and later to make a zip file to attach to email.
      Now I got the last step to make that is to delete the files from directory after the email sending .
      Also here there is a small probably syntax issue...



      part of code for sending email - If someone is interested on it .
      ==================
      $row_nr = "SELECT COUNT(*) as nr_rows FROM `tb_documents_active` WHERE `fld_document_id` = [glo_protocollo]";
      sc_lookup(rs_rownr, $row_nr);
      if (isset({rs_rownr[0][0]})) // Row found
      {
      $nr_rows = {rs_rownr[0][0]};
      }

      //Read attached files
      $query = "SELECT `fld_filename` FROM `tb_documents_active` WHERE `fld_document_id` = [glo_protocollo] ";

      sc_lookup(rs_attach, $query);

      if (isset({rs_attach[0][0]})) // Row found
      {
      $r=0; $total_files = ''; $mail_attachments = '';

      $zipfilename = 'PROTOCOLLO NR '. [glo_fld_protocol] . " Data " . date("d-m-Y") . '.zip';
      $zip = new ZipArchive();

      $zip->open($zipfilename, ZipArchive::CREATE);
      foreach ({rs_attach} as $file)
      {
      $namefile = {rs_attach[$r][0]};
      $zip->addFile($namefile);
      $r=$r+1;
      }
      $zip->close();

      }

      $mail_attachments = $zipfilename;

      sc_mail_send($mail_smtp_server.............. so on
      ==========================


      The issue is now here after the email sending

      ==========================
      if ({sc_mail_ok})
      {
      $r1=0;
      foreach ({rs_attach} as $file1)
      {
      $namefile1 = {rs_attach[$r1][0]};
      echo "FILES " . "'". dirname(__FILE__) .'/'. $namefile1 ."'" ;
      unlink([path_file_name] .'/'. $namefile1);
      $r1=$r1+1;
      }
      unlink([path_file_name] .'/'. $zipfilename);

      echo "<script>window.alert('Inviata nr {sc_mail_count} e-mail(s) con successo.');</script>";
      }

      =====================

      With the above code I can delete the ZIP file but not the attached file saved on server directory

      the error and file are here. files are 01.png , 02.png and 03.png (seems all correct but it doesn't work !!)

      unlink('/home/eosbbaho/public_html/eos_protocollo/mails_select_list_form/01.png'): No such file or directory

      Script: /home/eosbbaho/public_html/eos_protocollo/mails_select_list_form/mails_select_list_form_apl.php (2175)
      unlink('/home/eosbbaho/public_html/eos_protocollo/mails_select_list_form/02.png'): No such file or directory

      Script: /home/eosbbaho/public_html/eos_protocollo/mails_select_list_form/mails_select_list_form_apl.php (2175)
      unlink('/home/eosbbaho/public_html/eos_protocollo/mails_select_list_form/03.png'): No such file or directory

      Script: /home/eosbbaho/public_html/eos_protocollo/mails_select_list_form/mails_select_list_form_apl.php (2175)

      Comment

      Working...
      X