We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Sending Email

Can any one please tell me how to send emails using phalcon framework as I am new to this framework

edited Oct '15

In Phalcon integreted mail function is absent use https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Mailer or https://github.com/vanchelo/phalcon-mailer . First is more tested but second can work with queue. And both depend SwiftMailer

As a side note, the reason Phalcon doesn't have an integrated mail system is because there will be no real advantage of a mailing system written in Zephir. Most of the time is spent sending the emails and not executting the code

can i have to install swift mailer first then add the phalcon library or swift mailer is already installed on phalcon framework.

install swift mailer first and then the phalcon library

edited Oct '15

I used SendGrid and it's super simple. You'll need to sign up with sendgrid and include with composer. Simple use as follows:

    public function sendActivationEmail() {
        $sendgrid = new SendGrid('[username]', '[password]');
        $email = new SendGrid\Email();
            ->setFrom("[email protected]")
            ->setSubject("Sending emails is super neat.")
                <p>Text is awesome for emails!  Love it.</p>

This method is called in the user object in the afterCreate(); [username] and [password] are your username and password w/ SendGrid.

Sendgrid also has support for templates and such, but I didn't take the time to figure them out.