How to send an email in background with CakePHP?
NickName:sonxurxo Ask DateTime:2012-09-05T01:15:08

How to send an email in background with CakePHP?

That's it, how can I send an email in background with CakePHP, preferable using the out-of-the-box Email component?

EDIT: with in background I mean in another thread, or at least allowing the controller method to finish and send the response to the user. I want to run a function, return "OK" to the user and, after that, send an email.

If it's not possible, how could I do it using the PHP mail function? (only if it's a good approach)

Don't know if it matters, but I'm using SMTP.

Thank you in advance.

EDIT 2: I'm trying to use the CakeEmail::deliver() method, as I read from the documentation that:

Sometimes you need a quick way to fire off an email, and you don’t necessarily want do setup a bunch of configuration ahead of time. CakeEmail::deliver() is intended for that purpose.

I'm trying this:

CakeEmail::deliver('[email protected]', 'Test', 'Test',
                array('from' => '[email protected]'), true);

But the mail is not actually being sent. Anyone has any hint on that method?

Copyright Notice:Content Author:「sonxurxo」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12268361/how-to-send-an-email-in-background-with-cakephp

More about “How to send an email in background with CakePHP?” related questions

How to send an email in background with CakePHP?

That's it, how can I send an email in background with CakePHP, preferable using the out-of-the-box Email component? EDIT: with in background I mean in another thread, or at least allowing the cont...

Show Detail

Email is not send in CakePHP

I am working with CakePHP version 1.3.13. Here, I want to send mail. So I have written code like this : function send_mail_to_client() { $text = "sending mail"; App::uses('CakeEmail', '

Show Detail

cakephp send batch email with dynamic content

I had a strange problem with email sending through cakephp and postmark. I have installed postmark-cakephp library in my cakephp application. I'm able to send email to single user and able to send...

Show Detail

Checking if an email was send using CakePHP 2.3

I would like to check whether the email has been sent or not. (in case the email is incorrect, or the server is down... or whatever) As the Email component is deprecated, now the value returned by...

Show Detail

CakePHP passing variables to send email with CakeEmail

In CakePHP 2.x how can I create variables in a form in order to pass it to the CakeEmail function? I currently have a php file 'email.php' that has a form with inputs 'to', 'subject' and 'message'...

Show Detail

how to send email using cakephp email component?

I try to send a mail using cakephp email component. But mail is not delivering, nor it shows any error message. do i need to set any additional parameters? here is my code snippet: $th...

Show Detail

CakePHP : send email with attachment via console

I'm trying to send out emails with the CakePHP 1.3 email component via console/cron. The emails are sent out & received, but without the attachment. When done via form, the emails are sent wit...

Show Detail

cakephp send mass email cron job

i wish to send mass email using cakephp shell cron job. I started with sending mail to a single person. It isn't working. Below is my code: <?php error_reporting(0); class MyShell extends...

Show Detail

Cannot send email in CakePhp

I make API for send email using cakephp. This is my code: App::uses('CakeEmail', 'Network/Email'); $this->autoLayout = false; $this->autoRender = false; $data...

Show Detail

Cakephp unable to send email

I want to use the cakePHP mailer system, but I am unable to send an email, I get the following error: Fatal error: Class 'CakeEmail' not found in D:... on line 100 I have the following defined i...

Show Detail