Page 1 of 1

[solved] Forwarding news module posts to an email address

Posted: Mon May 14, 2012 11:09 am
by swarfega
Is it possible to get the news module to automically forward a new post to an email address, possibly in html format?

Re: Forwarding news module posts to an email address

Posted: Mon May 14, 2012 3:16 pm
by staartmees
(1) use this UDT and call it e.g. sending news

Code: Select all

$gCms = cmsms(); //global $gCms;
$editedby = $gCms->variables['username'];
$bodytext = 'start of the text.<br /><br>On ' . date('l j F Y', $params['start_time']) . ' a new message was posted on www.yourwebsite.com.<br><br><hr>
<h2> ' . $params['title'] . '</h2>
<br />' . $params['summary'] . '<br /><br />
 '. $params['content'].'<br clear="right"><br>';
$cmsmailer =& cms_utils::get_module('CMSMailer');
$cmsmailer->SetFrom('sending emailaddress');
$cmsmailer->SetFromName('name sending emailaddress');
$cmsmailer->AddAddress('destination emailaddress', $name='name destination emailaddress');
$cmsmailer->SetBody($bodytext);
$cmsmailer->IsHTML(true);
$cmsmailer->SetSubject('titel of email ');
$cmsmailer->Send();
(2) Call this UDT when adding news with the Event manager

Re: Forwarding news module posts to an email address

Posted: Mon May 14, 2012 3:29 pm
by swarfega
Thank you, will try this out.

Re: Forwarding news module posts to an email address

Posted: Mon May 14, 2012 3:37 pm
by manuel
Me too ;)

Greetings,
Manuel

Re: Forwarding news module posts to an email address

Posted: Mon Aug 20, 2012 6:46 pm
by swarfega
I can confirm this script works. Thanks for the response.

(sorry for the long delay, but I had problems getting this script added to the udt as the hosters security kept bouncing it.)

Re: [solved] Forwarding news module posts to an email addres

Posted: Tue Aug 21, 2012 12:43 pm
by swarfega
Just a quick question, am I able to include attachments at all? Currently I use the attachments module to attach files like pdfs to a news article after the news article has been submitted.