Page 2 of 2

Re: Sending reports with e-mail - alternative option

Posted: Thu Aug 01, 2019 12:07 am
by nc07
Janusz wrote:Yeah :-)
it's working
thanks a lot Kev1n
Hi Januz,

Would you assist me with sending email from the database probably with a demo video. I am trying to follow this post to set up but unsuccessful.

Appreciate your time and assistance.

nc07

Re: Sending reports with e-mail - alternative option

Posted: Thu Aug 01, 2019 5:23 pm
by Janusz
Hi,
Please find enclosed video with example how to set-up an email on completelly new nuBuilder instalation.
https://drive.google.com/file/d/1SaZFi- ... sp=sharing

basic steps:
1. Configure mail service in nuBuilder
as in video just use you mail data

2. Create procedure to send e-mail

Code: my_mail
Description: Mail
Run: Hidden

PHP (in the box):

Code: Select all

$to='jr_test@wp.pl'; 
$body= 
'Hi, 
This is email from nuBuilder. 

Regards 
Janusz'; 
$subj='Test #1'; 
$att=''; 
//$filesource = './upload-target/logo.png'; 
//$filename = 'logo.png'; 
//$att=array($filename => $filesource); 
nuSendEmail( $to, '', '', $body, $subj, $att, false);
3. Create button:

Label: Send Mail
ID: FF_but_mymail
onclick: nuRunPHPHidden('my_mail');

AND that's all.
If you press the button - then the mail will be sent to the given address
(in this case to jr_test@wp.pl)

If you want to send attachement - in the next step - unmark the lines in the php procedure and place the file in the folder.

Janusz

Re: Sending reports with e-mail - alternative option

Posted: Mon Aug 19, 2019 5:18 am
by nc07
Thanks, Janusz for your time and help.

I managed to set up the email function and all works well. The email attachments also worked fine when the file is placed in the folder.

A bit more to the attachment, how can I output a report to PDF and same is sent through email without manually saving it in the folder on the server. As per your assistance earlier, my pdf outputs with few fields data that it is not saving automatically to the server. Any suggestions on how this can be done.

Re: Sending reports with e-mail - alternative option

Posted: Mon Aug 19, 2019 7:38 am
by Janusz
Hi,
Normally you can apply the idea from the following post:
https://forums.nubuilder.cloud/viewtopic. ... 905#p19177
modifed nurunpdf.php
......
$PDF->Output('nureport.pdf', 'I');
// 2 lines belowe were added
$PDF->Output('/var/www/html/TestDB/uploads/nureport.pdf', 'F');
$y = shell_exec('send_pdf.sh');
// end
nuRemoveFiles();
.........
and replace the $y = shell_exec('send_pdf.sh'); with nuSendEmail(.....)

Re: Sending reports with e-mail - alternative option

Posted: Tue Aug 20, 2019 3:59 am
by nc07
Thank you, Janusz,

Your assistance and time are much appreciated.

After a few errors, I managed to get it working, thanks once again.

Regards
nc07

Re: Sending reports with e-mail - alternative option

Posted: Tue Aug 20, 2019 6:15 am
by nc07
Hi,

Is there any way to reduce the size of the PDF file as at the moment it outputs to about 1.78 MB which is not really that huge but just wondering if it is possible which might reduce the upload time.

regards
nc07

Re: Sending reports with e-mail - alternative option

Posted: Tue Aug 20, 2019 2:43 pm
by Janusz
Hi,
You can exclude fonts attachement to the generated pdf file.

in the nurunpdf.php at line c.a. 33

comment as following:

Code: Select all

//for($i = 0 ; $i < count($fl) ; $i++){
//      $fnt                                    = $fl[$i][0];
//      $PDF->AddFont($fnt, '', '', true);
//}
this should reduce the size from about 1.8M to few KB

Re: Sending reports with e-mail - alternative option

Posted: Thu Aug 22, 2019 3:18 am
by nc07
Janusz wrote:Hi,
You can exclude fonts attachement to the generated pdf file.

in the nurunpdf.php at line c.a. 33

comment as following:

Code: Select all

//for($i = 0 ; $i < count($fl) ; $i++){
//      $fnt                                    = $fl[$i][0];
//      $PDF->AddFont($fnt, '', '', true);
//}
this should reduce the size from about 1.8M to few KB
Thanks Janusz,

This has really helped reduce the file size to 30kb which had decrease the upload time.

Really appreciated.

best regards,
nc07