[nycphp-talk] Help Finding an HTML Email View in CakePHP Application
John Campbell
jcampbell1 at gmail.com
Wed Jul 1 12:10:54 EDT 2009
It looks like the html is in the database.
The message is generated from $result['Invoice']['invoice'].
My guess is the invoice is generated somewhere else and stored in
database, as a permanent record. This email code is just retrieving
the html from the database and sending it.
On Wed, Jul 1, 2009 at 11: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