1

I try to send a simple Email via CakePHP's Email Component. I'm using following code from the cookbook documentation:

$this->Email->from    = 'Irgendjemand <[email protected]>';
$this->Email->to      = 'Irgendjemand Anderes <[email protected]>';
$this->Email->subject = 'Test';
$this->Email->send('Dies ist der Nachrichtenrumpf!');

The send()-method does only return a boolean value with the value false - but no error or warning occurs.

Does somebody have a solution for that?

1
  • Does PHP's vanilla mail() function do anything? Is this a shared hosting environment? Where is your smtp server? How is that configured? Need more info...
    – Mike B
    Oct 12, 2009 at 17:13

3 Answers 3

3

Have you tried changing the delivery options? There are three options: mail, smtp and debug.

$this->Email->delivery = 'debug';
$this->Email->send('test message');
debug($this->Session->read('Message.email'));
3

You can debug with EMail. Set the delivery to debug and the email message will be set to Session.message:

if (Configure::read('debug') > 1) {
    $this->Email->delivery = 'debug';
}
$ret = $this->Email->send();
if (Configure::read('debug') > 1) {
    pr($this->Session->read('Message.email'));
}
0

Which OS are you on? If Windows, this note may be of interest:

Note: The Windows implementation of mail() differs in many ways from the Unix implementation.
...
As such, the to parameter should not be an address in the form of
"Something <[email protected]>". The mail command may not parse this properly while talking with the MTA.

Secondly, it may just be the case that no mail server will accept outgoing mail from your local machine due to spam protection. I have often seen that the same mail() function will not work locally, but works fine once uploaded to a trustworthy server. You could try to use an authenticated mail relay in that case (SMTP).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.