Page 1 of 1

SOLVED: How to use new cms_mailer-class in UDT?

Posted: Thu Feb 18, 2016 11:32 am
by Freud
In the CMSMS 1.* series I was used to use the CMSMailer-module to send mails in user defined tags.
I've read that in CMSMS 2.* the mail-API is pat of the core and that there is no need to install the CMSMailer-module anymore.
I have found the cms_mailer-class in the API-documentation, but I can't seem to get it to work in an UDT and I can't find any example-code for this.
Can anybody help me with that?

Re: How to use new cms_mailer-class in UDT?

Posted: Thu Feb 18, 2016 3:09 pm
by calguy1000
There are no examples, because it's really simple. You no longer need to get the instance of the CMSMailer module, just create a new cms_mailer object.

Code: Select all

$mailer = new \cms_mailer;
$mailer->SetSubject($subject);
$mailer->SetBody($body);
$mailer->AddAddress($email);
$mailer->Send();

SOLVED: How to use new cms_mailer-class in UDT?

Posted: Thu Feb 18, 2016 3:13 pm
by Freud
That's realy simple!
It was that first line of code that I was looking for.
Changed my UDT, tested it and it works.
Thanks for your help!