Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Send email notification to specific emails after PO was created
07-17-2013, 01:26 PM,
#1
Send email notification to specific emails after PO was created
Hello, any idea how to send email notification to specific email after Purchase order was created?

i am planning to put some emails (about 5 emails) on setup menu, which is used to send emails notification after someone created purchase order..

what do you all think?
Reply
07-17-2013, 04:21 PM,
#2
RE: Send email notification to specific emails after PO was created
Why not...
You would need to perhaps link this to change of the status of the PO to authorised so off PO_Header.php
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply
07-17-2013, 04:41 PM, (This post was last modified: 07-17-2013, 04:57 PM by kelo.)
#3
RE: Send email notification to specific emails after PO was created
Hi phil,

thanks for reply..

it is better to create new table to save the emails, or just put the emails at the specific existing table?

and i see in the include/ folder there is smtp.php file, how to use that for sending email?

thanks..
Reply
07-17-2013, 06:47 PM,
#4
RE: Send email notification to specific emails after PO was created
Hi, Kelo:

The email features have been reworked in the trunk. A mailing lists maintenance scripts have been added. You can download the trunk to check if it meets your requirements.

Best regards!

Exson
Reply
07-18-2013, 07:21 AM, (This post was last modified: 07-18-2013, 07:23 AM by phil.)
#5
RE: Send email notification to specific emails after PO was created
Best to study an existing script that already sends emails - e.g. PO_PDFPurchOrder.php the guts of the email stuff starts at line 318:
Code:
} else {
        /* must be MakingPDF to email it */

        $PdfFileName = $_SESSION['DatabaseName'] . '_PurchaseOrder_' . $OrderNo . '_' . date('Y-m-d') . '.pdf';
        $pdf->Output($_SESSION['reports_dir'] . '/' . $PdfFileName, 'F');
        $pdf->__destruct();
        include('includes/htmlMimeMail.php');
        $mail = new htmlMimeMail();
        $attachment = $mail->getFile($_SESSION['reports_dir'] . '/' . $PdfFileName);
        $mail->setText(_('Please find herewith our purchase order number') . ' ' . $OrderNo);
        $mail->setSubject(_('Purchase Order Number') . ' ' . $OrderNo);
        $mail->addAttachment($attachment, $PdfFileName, 'application/pdf');
        //since sometime the mail server required to verify the users, so must set this information.
        if($_SESSION['SmtpSetting'] == 0){//use the mail service provice by the server.
            $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>');
            $Success = $mail->send(array($_POST['EmailTo']));
        }else if($_SESSION['SmtpSetting'] == 1) {
            $Success = SendmailBySmtp($mail,array($_POST['EmailTo']));
        
        }else{
            prnMsg(_('The SMTP settings are wrong, please ask administrator for help'),'error');
            exit;
            include('includes/footer.inc');
        }
        
        if ($Success == 1) {
            $Title = _('Email a Purchase Order');
            include('includes/header.inc');
            echo '<div class="centre"><br /><br /><br />';
            prnMsg(_('Purchase Order') . ' ' . $OrderNo . ' ' . _('has been emailed to') . ' ' . $_POST['EmailTo'] . ' ' . _('as directed'), 'success');

        } else { //email failed
            $Title = _('Email a Purchase Order');
            include('includes/header.inc');
            echo '<div class="centre"><br /><br /><br />';
            prnMsg(_('Emailing Purchase order') . ' ' . $OrderNo . ' ' . _('to') . ' ' . $_POST['EmailTo'] . ' ' . _('failed'), 'error');
        }
    }

I don't see any need to retain these emails - as the order can be reprinted at any time and the mail log will contain details of emails sent/inbox of the mail clients can file emails as necessary. Just adding to the backup burden IMHO
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply
07-18-2013, 12:26 PM,
#6
RE: Send email notification to specific emails after PO was created
(07-18-2013, 07:21 AM)phil Wrote: Best to study an existing script that already sends emails - e.g. PO_PDFPurchOrder.php the guts of the email stuff starts at line 318:
Code:
} else {
        /* must be MakingPDF to email it */

        $PdfFileName = $_SESSION['DatabaseName'] . '_PurchaseOrder_' . $OrderNo . '_' . date('Y-m-d') . '.pdf';
        $pdf->Output($_SESSION['reports_dir'] . '/' . $PdfFileName, 'F');
        $pdf->__destruct();
        include('includes/htmlMimeMail.php');
        $mail = new htmlMimeMail();
        $attachment = $mail->getFile($_SESSION['reports_dir'] . '/' . $PdfFileName);
        $mail->setText(_('Please find herewith our purchase order number') . ' ' . $OrderNo);
        $mail->setSubject(_('Purchase Order Number') . ' ' . $OrderNo);
        $mail->addAttachment($attachment, $PdfFileName, 'application/pdf');
        //since sometime the mail server required to verify the users, so must set this information.
        if($_SESSION['SmtpSetting'] == 0){//use the mail service provice by the server.
            $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>');
            $Success = $mail->send(array($_POST['EmailTo']));
        }else if($_SESSION['SmtpSetting'] == 1) {
            $Success = SendmailBySmtp($mail,array($_POST['EmailTo']));
        
        }else{
            prnMsg(_('The SMTP settings are wrong, please ask administrator for help'),'error');
            exit;
            include('includes/footer.inc');
        }
        
        if ($Success == 1) {
            $Title = _('Email a Purchase Order');
            include('includes/header.inc');
            echo '<div class="centre"><br /><br /><br />';
            prnMsg(_('Purchase Order') . ' ' . $OrderNo . ' ' . _('has been emailed to') . ' ' . $_POST['EmailTo'] . ' ' . _('as directed'), 'success');

        } else { //email failed
            $Title = _('Email a Purchase Order');
            include('includes/header.inc');
            echo '<div class="centre"><br /><br /><br />';
            prnMsg(_('Emailing Purchase order') . ' ' . $OrderNo . ' ' . _('to') . ' ' . $_POST['EmailTo'] . ' ' . _('failed'), 'error');
        }
    }

I don't see any need to retain these emails - as the order can be reprinted at any time and the mail log will contain details of emails sent/inbox of the mail clients can file emails as necessary. Just adding to the backup burden IMHO

thanks phil, this is very helpfull..
i need this send email just as an notification to specific emails with only msg like "New Purchase order has been created by " . $user or something like that..
and how to cc 1 email to other lets say 5 emails?
Reply
07-18-2013, 12:32 PM, (This post was last modified: 07-18-2013, 12:35 PM by phil.)
#7
RE: Send email notification to specific emails after PO was created
as you can see above we use the class htmlMimeMail()
the docs are at:
http://www.masmi.com/masmic5_v2by/utilit...eMail.html

setcc

is what you are after. Unfortunately, this documentation is next to useless as much of the phpdoc documentation tends to be

see

http://www.schogini.com/articles/Sending...h-PHP.html

for a tutuorial on send email using htmMimeEmail
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)