Announcement

Collapse
No announcement yet.

MailSender in Controller

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MailSender in Controller

    Hi,
    I will send a email in a controller, but receive :

    Call to undefined method Espo\\Custom\\Controllers\\Contact::getMailSender( ) at custom/Espo/Custom/Controllers/Contact.php

    It's certainly easy .. but I lag

    Regards

    PHP Code:
    namespace Espo\Custom\Controllers;

    use 
    \Espo\ORM\Entity;
    use 
    \Espo\Entities;
    use 
    \Espo\Core\Utils\Util;
    use 
    \Espo\Entities\Email;


    class 
    Contact extends \Espo\Core\Templates\Controllers\Person
    {
            
    $email $this->getEntityManager()->getEntity('Email');
            
    $email->set([
                
    'to' => 'to@mailsender.net',
                
    'subject' => 'subject',
                
    'body' => 'body',
                
    'isHtml' => false
            
    ]);

            
    $this->getMailSender()->send($email);

            return 
    true;




  • #2
    Hi,
    you need to define this method, like here https://github.com/espocrm/espocrm/b...sEmail.php#L57
    but better do it in Service, not in controller.

    Comment


    • #3
      Hi Tanya,
      I have try but not understand .. what is "service" ?
      Yes I see in directory, in file, in documentation about workflow .. what is the "role" of service ? when need that ?
      Hook, Controller.. it's ok for me.. but service .. if you can a little explain ..
      Regards

      Comment


      • #4
        Hello,
        in general controllers in EspoCRM is used for ACL check (permissions) and call service method
        Hi, I was doing some code additions in the EspoCRM\application\Espo\Modules\Crm\Services\Account.php. From all I see I am pretty sure that if there is an

        btw, in your controller I can't find any method...

        Comment

        Working...
        X