Giter Club home page Giter Club logo

Comments (4)

emog avatar emog commented on August 16, 2024

I try the next:

$di->set('mail', function() {
require_once DIR . '/../app/vendor/Swift/lib/swift_required.php';
$config = new Phalcon\Config\Adapter\Ini(DIR . '/../app/config/mail.ini');
$mailer = new Phalcon\Mailer\Manager(array(
"driver" => $config->mail->driver,
"host" => $config->mail->host,
"port" => $config->mail->port,
'encryption' => $config->mail->encryption,
'username' => $config->mail->username,
'password' => $config->mail->password,
'from' => array("email" => $config->mail->fromEmail, "name" => $config->mail->fromName)
));
return $mailer->createMessage();
});

When call

$this->getDI()->getMail()
->to(array($this->email => $this->rname))
->subject('User Registration')
->createMessageFromView('emailTemplates\newuser' , array('password' => 'asdasdas'));

I get error:
Fatal error: Class 'Phalcon\Mailer\Manager' not found in /var/www/html/new/public/index.php on line 214

I have the two files located at my app/plugins directory which is included in my loader, because i use other files from the same directory.

I try to include the files after requirement of Swift but i get another error.

from incubator.

KorsaR-ZN avatar KorsaR-ZN commented on August 16, 2024

@advokata

  1. replace "return $mailer->createMessage();" to "return $mailer"
  2. switfMailer version >= 5.2
  3. run composer install
  4. include /vendor/autoload.php
  5. PROFIT

createMessageFromView()

/**
 * Global viewsDir for current instance Mailer\Manager.
 * 
 * This parameter is OPTIONAL, If it is not specified, 
 * use DI from view service (getViewsDir)
 */
$config['viewsDir'] = __DIR__ . '/views/email/';

$mailer = new \Phalcon\Mailer\Manager($config);

// view relative to the folder viewsDir (REQUIRED)
$viewPath = 'email/example_message';

// Set variables to views (OPTIONAL)
$params [ 
    'var1' => 'VAR VALUE 1',
    'var2' => 'VAR VALUE 2',
    ...
    'varN' => 'VAR VALUE N',
];

/**
 * The local path to the folder viewsDir only this message. (OPTIONAL)
 * 
 * This parameter is OPTIONAL, If it is not specified, 
 * use global parameter "viewsDir" from configuration.
 */
$viewsDirLocal = __DIR__ . '/views/email/local/';


$message = $mailer->createMessageFromView($viewPath, $params, $viewsDirLocal)
        ->to('[email protected]', 'OPTIONAL NAME')
        ->subject('Hello world!');

// Set the Cc addresses of this message.
$message->cc('[email protected]');

// Set the Bcc addresses of this message.
$message->bcc('[email protected]');

// Send message
$message->send();

from incubator.

sergeyklay avatar sergeyklay commented on August 16, 2024

@advokata this is solved?

from incubator.

emog avatar emog commented on August 16, 2024

I didn't try again. I have switched to Phalcon\Ext\Mailer which is the same but without this bug.

from incubator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.