0

I am trying to get CakeEmail working and I am getting a "Could not send email" Internal Error.

The last line of the stack trace is

CORE/Cake/Network/Email/MailTransport.php line 47 -> MailTransport->_mail(string,string,string,string,null)

In my email.php config I have

class EmailConfig {

    public $default = array(
        'transport' => 'Mail',
        'from' => 'no-reply@xxxxx.com.au'
        );
}

I receive my email address from a form and am trying to send an email to the subscriber. My code is as follows

$email_addr = $subs_data['Subscriber']['subscriber'];

$Email = new CakeEmail('default');

$Email->emailFormat('html')
      ->template('welcome')
      ->to($email_addr)
      ->subject('New Subscription')
      ->send();

I have done some testing and the value in $email_addr is exactly what is coming from the form and is a valid Email address.

I have a template in View/Emails/html/welcome.ctp that for now is just a very basic message

Looking at the stack trace and line 47 in MailTransport.php I have found the error appears to be to do with the "to" email address. I can not see what is wrong with it though. I have looked at a lot of examples and as far as I can tell I am not doing anything wrong.

I would appreciate any help so I could get this application finished.

Kind Regards

Richard

4

3 に答える 3

1

EmailConfig に構成を追加する必要があります。

私のコードを見てください:

class EmailConfig {    
    public $fast = array(    
        'transport' => 'Smtp',    
        'from' => array('test_mail@gmail.com' => 'Test Mail name sender'),    
        'host' => 'ssl://smtp.gmail.com',    
        'port' => 465,    
        'username' => 'test_mail@gmail.com',    
        'password' => 'password');    
}

そしてコントローラーで:

CakeEmail::deliver('to@gmail.com', 'Subject', 'Content');

それでおしまい!

于 2013-07-16T07:01:25.793 に答える
0

email.php で次の構成を試してください。

public $default = array(
    'transport' => 'Mail',
    'from' => 'abc@my-domain.com',
    'charset' => 'utf-8',
    'headerCharset' => 'utf-8'
);
于 2013-07-16T07:10:27.807 に答える