Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Sending Email

Hi guys,

Can somebody explain to me on how did the send method get its parameter values, especially the $to, $subject, in the Mail object in the project of @Thien anyway here is the link of his project

Thnks :)



I use swift mailer so you understand it via


For me i am using Sendgrid api for sending emails in my phalcon app.

Developers can send up to 100 emails per day for free.

@Thien yes i understand that you used Swift mailer to send email, but my question is, how and where did the $to, $subject get its values in the send method? Sorry to bother you man. :)

@Derek thanks for that suggestion.

edited Nov '14


You can call anywhere in some case I call in model when user register accont

And $to is email of user

big big thanks @Thien :) .

edited Dec '14

@Thien i got some warning message on my screen when sending email and i cannot figure out whats causing it.

Warning: Phalcon\DI\Injectable::__get(): Access to undefined property AppMail::_transport in C:\Users\spilagan20140973\Desktop\xammp1\htdocs\PHALCON\app\mail\AppMail.php on line 30



require_once __DIR__ . '/SwiftMail/swift_required.php';

use \Phalcon\Mvc\User\Component,

class AppMail extends Component{

     * sends email after register
     * @param string $to
     * @param string $subject
     * @param string $message
    public function sendMail($to, $subject, $message){

        $mailSettings = $this->config->mail;

        // Create the message
        $message = Swift_Message::newInstance()
                $mailSettings->fromEmail => $mailSettings->fromName
            ->setBody($message, 'text/html');

            if (!$this->_transport) {
                $this->_transport = Swift_SmtpTransport::newInstance(
            // Create the Mailer using your created Transport
            $mailer = Swift_Mailer::newInstance($this->_transport);
            return $mailer->send($message);

i dont know where to find the _transport method or object and the wierd part is it send the email twice



In class AppMail you need to add property protected variable _transport look like:

    class AppMail extends Component{

    protected $_transport;


@Thien thnks, no more warning issues but it still send the email twice. Did u encounter this kind of issue before?


Not yet:)

edited Dec '14

owwww no, but anyway thnks 4 ur help :)