More Zend Framework Fun

Sending email via Gmail

  $config = array(
      'ssl' => 'tls',
      'port' => 587,
      'auth' => 'login',
      'username' => 'youemail@gmail.com',
      'password' => 'yourpassword'
  );
 
  $gmail = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
  $mail = new Zend_Mail();
  $mail->addTo($this->to);
  $mail->setSubject($this->subject);
  $mail->setFrom($this->from);
  $mail->setBodyText($this->body);
 
  $mail->send($gmail);

As you can see, you need to create an object for Gmail, then create an email object, then tell the email object to use the gmail object. It works great.


Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <drupal5>, <drupal6>, <javascript>, <php>, <sql>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options