[nycphp-talk] Help Finding an HTML Email View in CakePHP Application
Brian D.
brian at realm3.com
Wed Jul 1 12:05:25 EDT 2009
It looks to me like it's pulling data from the 'Invoices.invoice'
column in the database, replacing string tokens, and using it as the
message body.
-Brian
realm3 web applications [realm3.com]
Information architecture, application development.
phone: (917) 512-3594
fax: (440) 744-3559
On Wed, Jul 1, 2009 at 10:32 AM, Randal Rust<randalrust at gmail.com> wrote:
> We have inherited a CakePHP application that sends a formatted HTML
> email when someone completes the site's registration process. The
> method that invokes the email is:
>
> $this->Invoice->send($districtInfo['District']['invoiceEmail'], 'PO
> Order', $insert_data)
>
> The problem I'm having is that I cannot find the view for the HTML
> formatting. If I look at the Invoice model, I cannot figure out where
> the code (see below) calls the view. This does not seem to follow
> anything that I see here:
>
> http://book.cakephp.org/view/269/Sending-a-basic-message
>
> ============================================
>
> function send($email, $invoice_id, $insert_data)
> {
> if (! preg_match(VALID_EMAIL, $email)) {
> return false;
> }
> if (preg_match('/^[0-9]{1,10}$/', $invoice_id)) {
> $result = $this->find(('`Invoice`.`id` = ' .
> $invoice_id));
> } else {
> $result = $this->find(('`Invoice`.`name` = "' .
> $this->mrClean->sql($invoice_id) . '"'));
> }
> if (empty($result)) {
> return false;
> }
>
> $tokens = array();
> $replacements = array();
> foreach ($insert_data as $key => $value) {
> $tokens[] = '%' . $key . '%';
> $replacements[] = $value;
> }
> $message = str_replace($tokens, $replacements,
> $result['Invoice']['invoice']);
> $headers = 'MIME-Version: 1.0' . "\r\n" .
> 'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
> 'From: ' . $this->adminEmail . "\r\n" .
> 'Reply-To: ' . $this->adminEmail . "\r\n" .
> 'Bcc: ' . 'test at example.com' . "\r\n" .
> 'X-Mailer: PHP/' . phpversion();
> if (mail($email, $result['Invoice']['name'], $message, $headers,
> ('-f' . $this->adminEmail)) &&
> mail($this->adminEmail, $result['Invoice']['name'], $message,
> $headers, ('-f' . $this->adminEmail))) {
> return true;
> } else {
> return false;
> }
> }
>
> Apologies to anyone on Evolt for the cross-post. That was not
> intentional. I picked the wrong email address.
>
> --
> Randal Rust
> R.Squared Communications
> www.r2communications.com
> 614-370-0036
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
>
More information about the talk
mailing list