Topic: need help with multiple attachments (Read 2203 times)
What a dork
Posts: 17
106 credits Members referred : 0
« on: Apr 23, 2007, 03:45:26 PM »
Hello Olaf Lederer!
How r u. I am Qasim Ali. I am using your Attachment Mailer class. Its a wonderful class and works well for email attachment using one attachment currently. I want to modify it for multiple attachements. But somehow i am not getting it right. I am sending you the code for what i am doing currently. Please help me modify it for multiple attachments.
What a dork
Posts: 17
106 credits Members referred : 0
« Reply #6 on: Apr 23, 2007, 04:58:24 PM »
Oh no $num_files is not the problem, i just didn't copied the whole code, If you want to see the whole page its attached in the first post. The problem lies here
Hi! i am not telling u to fix it, i am just asking that where i am wrong in the following code since it was not working.
Oh no $num_files is not the problem, i just didn't copied the whole code, If you want to see the whole page its attached in the first post. The problem lies here
Hi! i am not telling u to fix it, i am just asking that where i am wrong in the following code since it was not working.
What a dork
Posts: 17
106 credits Members referred : 0
« Reply #10 on: Apr 24, 2007, 08:33:49 AM »
Hello Olaf!
Thanks for your help. I am very close to getting it done. The code give below works fine for one file, but when i upload two files it says "Error! Sorry, a file with this name already exitst." bit in my case their is no file in the directory of the same name. Please let me know whats the problem.
What a dork
Posts: 17
106 credits Members referred : 0
« Reply #12 on: Apr 24, 2007, 09:38:13 AM »
Hello Olaf!
Thanks! now one last thing, it gives an Error "Error, the file "" does not exist." when i try to upload files of two same extensions, other wise it works fine.
Shows following error
File: iamuploadingit today.zip successfully uploaded! The uploaded file is renamed to 1177397078.zip. Error, the file "" does not exist. Your mail is succesfully submitted.
Regards, Qasim
What a dork
Posts: 17
106 credits Members referred : 0
What a dork
Posts: 17
106 credits Members referred : 0
« Reply #15 on: Apr 24, 2007, 11:45:02 AM »
here it is
if(isset($_POST['Submit'])) { $my_mail = new attach_mailer($name = $_POST['from_name'], $from = $_POST['from_email'], $to = $_POST['mail_to'], $cc = "", $bcc = "", $subject = $_POST['mail_subject'], $body = $_POST['mail_body']); echo "<pre>"; var_dump($_FILES); echo "</pre>"; for ($i = 1; $i <= $num_files; $i++){ $my_upload = new file_upload; $my_upload->upload_dir = "/home/qasim/new/upload/100/"; // "files/mail" is the directory for the uploaded files (you have to create this directory) $my_upload->extensions = array(".png", ".zip", ".pdf", ".jpg",".txt",".doc",".gif"); // specify the allowed extensions here // $my_upload->extensions = "de"; // use this to switch the (upload) messages into an other language $my_upload->rename_file = true; // rename the file to get a valid file string in your mail
$my_upload->the_temp_file = $_FILES['upload'.$i]['tmp_name']; $my_upload->the_file = $_FILES['upload'.$i]['name']; $my_upload->http_error = $_FILES['upload'.$i]['error']; if ($my_upload->upload()) { //loop will go here $full_path = $my_upload->upload_dir.$my_upload->file_copy; echo $full_path; $files_uploaded[$i] = $full_path; $msg .= $my_upload->show_error_string(); //$my_mail->create_attachment_part($full_path); //$my_mail->process_mail(); //$my_mail->del_temp_file($full_path); // the file is not needed anymore } } for ($i = 1; $i <= $num_files; $i++){ $my_mail->create_attachment_part($files_uploaded[$i]); } $my_mail->process_mail(); $msg .= $my_mail->get_msg_str(); }
What a dork
Posts: 17
106 credits Members referred : 0
« Reply #16 on: Apr 24, 2007, 01:11:57 PM »
Hello Sir!
Its really a strange problem, its working fine for messages with differnent extensions but its creatin problems for same extension files. Have you got to any conclusion.
Thanks for you rcooperation.
Regards, Qasim
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6440
39464 credits Members referred : 374
What a dork
Posts: 17
106 credits Members referred : 0
« Reply #18 on: Apr 25, 2007, 07:34:32 AM »
Hello Olaf!
Its working fine now. One thing more, when i try to send email to multiple recipients comma separated, it fails and returns error as |Error, the "mailto" address is empty or not valid.
Please let me know how to handle this now.
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6440
39464 credits Members referred : 374
Its working fine now. One thing more, when i try to send email to multiple recipients comma separated, it fails and returns error as |Error, the "mailto" address is empty or not valid.
Please let me know how to handle this now.
this is fixed in the next version, while I think that sending mails this way is wrong, check the modification inside the method attach_mailer:
Code:
if (is_array($cc)) { // changed in version 1.03 $invalid_cc = array(); foreach ($cc as $c) { if (!$this->check_mail_address($c)) { $invalid_cc[] = $c; } } if (count($invalid_cc) > 0) { $this->msg[] = "Error, invalid \"Cc\"(s): ".implode(", ", $invalid_cc); $this->valid_mail_adresses = false; } } else { $cc = array(); }
if you change this you need to add email addresses as an array