The Contact Page: Sending the E-mail
Monday, November 9, 2009

The sending of the e-mail generated when the user submits a message via the contact page is handled by a class with a single method. This makes use of the Zend_Mail module to create and transmit the e-mail.

The class is implemented as follows:

<?php
class Default_Model_Mail_Contact
{
  public function send($bodyHtml)
  {
    // Send the mail
    $mail = new Zend_Mail();
    $mail->setBodyHtml($bodyHtml);
    $mail->setFrom('website@example.com', 'Website'); 
    $mail->addTo('admin@example.com', 'Admin');
    $mail->setSubject('Re: Message submitted via website');
    $mail->send();
  }
}

The send method creates a mail, which is sent to the account of the person who is responsible for handling enquiries. Most of the fields are fixed, except for the message body, which is generated in the action handler, then passed to the method.

Posted by James at 11:48 pm   0 comments

Leave a Reply