Issue getting ZipArchive to create a zip folder

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 1648 Views - Last Post: 30 October 2019 - 04:02 PM Rate Topic: -----

#16 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2494
  • View blog
  • Posts: 7,551
  • Joined: 15-January 14

Re: Issue getting ZipArchive to create a zip folder

Posted 30 October 2019 - 10:07 AM

No, you're not. Here's the function definition:

public static function mail_api(Array $msg, Array $filename = null, $template = null, $recipient = false, $attachment = null)

Where does it look like the attachment goes?

But let's look at that function a little closer. You also have a parameter called $filename, which should be an array. How does the function use that? Well, you've got this if statement:

if (!empty($file) && !$recipient && count($filename) > 1) {

And inside that if block, it uses $filename, and that's the only place it uses $filename (but only if it contains more than 1 filename). So, it's going to do that if $file is not empty, and also if $recipient is not false. Well, $file doesn't exist at all, so it's always going to be empty, so that if statement is never going to be true. I have no idea what the $recipient variable is supposed to do, you use it once here:

$message['to'] = !$recipient ? $email_to_send_to : $msg['email'];

So if it's false, then the "to" field will be $email_to_send_to, which also does not exist, and you use it here:

$message['h:Reply-To'] = !$recipient ? $msg['email'] : '';

So if it's false, the reply-to header will be $msg['email'].

Frankly, I have no idea what the purpose of some of that code is. When you call the function:
$to_company = Communication::mail_api($_POST, $filename, $template, 0);

You do in fact pass 0 for $recipient, so it's going to try to send the email to a variable that does not exist, and then do some other stuff (but never process the $filename array, since that if statement will never be true).
Was This Post Helpful? 0
  • +
  • -

#17 pfar54   User is offline

  • D.I.C Addict

Reputation: 1
  • View blog
  • Posts: 615
  • Joined: 30-April 15

Re: Issue getting ZipArchive to create a zip folder

Posted 30 October 2019 - 12:18 PM

I'm not sure where the attachment goes. I'm not actually defining it in the send file or sending it to the communication class, so it has to be defined in the Communication class. I was trying to send the attachment from the send file to the Communication class via $message["attachment[0]"]. Then in the Communication class it is defined further here:

 if ($attachment) {
            try {
                if (!file_exists($attachment)) {
                    throw new Exception("File $att


Even though the line of code below will never run, shouldn't the zip attachment be continued to the Communication class, making the section below obsolete?:

if (!empty($file) && !$recipient && count($filename) > 1) {



Some of the code I took out. Its mostly pertaining to real email addresses, domains, etc. The emails send to the correct addresses.
Was This Post Helpful? 0
  • +
  • -

#18 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2494
  • View blog
  • Posts: 7,551
  • Joined: 15-January 14

Re: Issue getting ZipArchive to create a zip folder

Posted 30 October 2019 - 04:02 PM

Quote

I'm not sure where the attachment goes.

I'm going to guess that it's the parameter called $attachment.

Quote

Even though the line of code below will never run, shouldn't the zip attachment be continued to the Communication class, making the section below obsolete?

If you decide to actually use the $attachment parameter then maybe it will.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2