I'm writing a small CakePHP application for an organization and have included a simple contact form that accepts an email address, subject, and message, and emails the message to the address.
Everything seems to work fine, and any email sent to myself or anyone at the organization arrives just fine, except if they access the message via POP, which most of them do. In this case, the email arrives with the subject, but the body is blank. The body shows up just fine, however, if the message is read via the webmail client.
Has anyone else run into this problem? Is it an issue with CakePHP, the email headers, or should I be talking to the hosting company? My code is based directly on the example given in the CakePHP documentation.
Here's the controller action that receives the request data and sends the email:
function send() {
if (!empty($this->data)) {
$contact = $this->Contact->read(null, $this->data['ContactMessage']['contact_id']);
$this->data['ContactMessage']['ip'] = $this->RequestHandler->getClientIp();
$this->ContactMessage->create();
if ($this->ContactMessage->save($this->data)) {
$this->Email->to = $contact['Contact']['email'];
$this->Email->subject = $this->data['ContactMessage']['subject'];
$this->Email->replyTo = $this->data['ContactMessage']['email'];
$this->Email->from = $this->data['ContactMessage']['email'];
$this->Email->sendAs = 'both';
$this->Email->send($this->data['ContactMessage']['message']);
$this->redirect(array('controller' => 'contacts', 'action' => 'thanks'));
} else {
$this->redirect(array('controller' => 'contacts', 'action' => 'oops'));
}
}
}