The Contact Page: Sending the E-mail


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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s