Hello
Is there a way to run a report save directly in PHP ??
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Run nurunpdf from PHP
Re: Run nurunpdf from PHP
Hi nathan,
Not with nuBuilder - but you can make nuBuilder wait for reports to be created on the server before attaching them to an email and sending it.
kev1n showed me here...
viewtopic.php?p=29928#p29928
I did this.. (It won't try to email anything until everything has been created.)
It won't send the email until window.file_list.length == window.invoices.length
Steven
Not with nuBuilder - but you can make nuBuilder wait for reports to be created on the server before attaching them to an email and sending it.
kev1n showed me here...
viewtopic.php?p=29928#p29928
I did this.. (It won't try to email anything until everything has been created.)
It won't send the email until window.file_list.length == window.invoices.length
Code: Select all
function build_invoice_list(){
window.file_list = [];
var inv = window.invoices;
for(var i = 0 ; i < inv .length ; i++){
nuSetValue('INVOICE_NUMBER', inv[i][0]);
nuRunReportSave('INV', window.invoices[i][1], email_invoice_list);
}
}
function email_invoice_list(a){
var inv = window.invoices;
var ino = window.invoices[window.file_list.length];
window.file_list.push([ino[1]+'.pdf', a]);
if(window.file_list.length == window.invoices.length){
nuRunPHPHiddenWithParams(window.INVOICE_TYPE, 'attachments', file_list, 1);
}
}
Steven
A short post is a good post.
Re: Run nurunpdf from PHP
This works for 1 email with 2 files attached
but i am trying to send 300+ emails with each a different attachment
when looping nuRunReportSave in JS it eventualy gives me a out og memory
but i am trying to send 300+ emails with each a different attachment
when looping nuRunReportSave in JS it eventualy gives me a out og memory
Re: Run nurunpdf from PHP
Hi nathan,
I asked chatGPT this question
And this is what it said about the PHP function nuBuilder uses...
Steven
I asked chatGPT this question
Is php's sendmail function good for sending bulk emails?
And this is what it said about the PHP function nuBuilder uses...
chatGPT wrote: Using PHP's mail() function (or sendmail) for sending bulk emails is generally not recommended for several reasons:
Limitations of PHP's mail() Function
Performance Issues:
The mail() function is not optimized for sending a large number of emails. Each call initiates a new connection to the mail server, which can be slow and resource-intensive.
Lack of Tracking:
The mail() function does not provide any built-in features for tracking email opens, bounces, or delivery status.
Scalability:
Sending thousands of emails using mail() can overwhelm your server resources, especially if your hosting plan has limited processing power or memory.
Risk of Being Marked as Spam:
Emails sent through mail() often lack proper headers (e.g., SPF, DKIM) and are more likely to be flagged as spam by recipient servers.
Shared hosting servers, in particular, are often blacklisted due to misuse by others on the same server.
No Queue Management:
There is no way to manage or queue emails efficiently. If your server crashes mid-process, you may lose track of which emails were sent.
Alternatives for Sending Bulk Emails
For bulk email campaigns, consider using more robust solutions:
1. Email Libraries:
Use libraries like PHPMailer or SwiftMailer with an SMTP service. These libraries offer better control, error handling, and support for advanced features like attachments, HTML emails, and headers.
2. Dedicated Bulk Email Services:
Services like Mailchimp, SendGrid, Amazon SES, Postmark, or Brevo (formerly Sendinblue) are specifically designed for bulk emails. They provide features like:
Delivery tracking
Bounce handling
Rate limiting
Compliance with spam regulations
Built-in templates and analytics
3. Self-Hosted Email Sending Solutions:
Use a tool like Postal or Mautic on a dedicated server. These tools allow you to set up and manage your own bulk email campaigns while handling the complexities of email deliverability.
4. Message Queues:
Implement a message queue system (e.g., RabbitMQ, Redis, or Amazon SQS) to manage the load and ensure emails are sent in a controlled and timely manner.
Conclusion
The mail() function is fine for sending a few emails in simple applications, but it is not a practical or reliable solution for bulk emailing. Using a professional email-sending service or a dedicated library with SMTP support is a much better approach for handling large volumes of email.
Steven
A short post is a good post.
-
- nuBuilder Team
- Posts: 506
- Joined: Fri Dec 28, 2018 1:41 pm
- Location: Krakow, Poland
- Has thanked: 8 times
- Been thanked: 18 times
Re: Run nurunpdf from PHP
Hi,
I did a try on my cloud VPS server: 1MB RAM, Linux Debian, with mail server running postfix.
Here I used a loop to send 1000 times the same email with attachment to the same e-mail address:
And as the results all 1000 mails were properly delivered 
In total it tooks probably around 30minutes until all mails were sent.
This time was not linked to the php mail service but due to the destination mailbox which was probably blocking itself by massive quanity of mails to accept. Because checking the postfix I could see:
But postfix was keeping sending all the emails. Looking on the destination mailbox I could see that the first c.a. 500 mails went quicly, bat remaining were apperaing in the batches of maybe 100 emails or less. And between such batches were even few minutes difference.
Just observation - they were received not reguraly, but finally every one was succesfully delivered: After moving them to the trash there was exactly 1000 emails
So my conlusion is: it's really possible to send bulk mails from PHP. Here I had one email destination. But in case there would be more different destinations then probably it would not be blocked by recepient mailbox and the whole batch could go faster.
I did a try on my cloud VPS server: 1MB RAM, Linux Debian, with mail server running postfix.
Here I used a loop to send 1000 times the same email with attachment to the same e-mail address:
Code: Select all
for($i = 1; $i <= 1000; $i++) {
$mail = @mail($to, $subject.$i, $message, $headers, $returnpath);
}

In total it tooks probably around 30minutes until all mails were sent.
This time was not linked to the php mail service but due to the destination mailbox which was probably blocking itself by massive quanity of mails to accept. Because checking the postfix I could see:
Code: Select all
(host mx5.wp.pl[123.123.123.123] said: 421 service temporarily unavailable (in reply to DATA command))
Just observation - they were received not reguraly, but finally every one was succesfully delivered: After moving them to the trash there was exactly 1000 emails

You do not have the required permissions to view the files attached to this post.
If you like nuBuilder, please leave a review on SourceForge