[solved] Forwarding news module posts to an email address

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

[solved] Forwarding news module posts to an email address

Post by swarfega »

Is it possible to get the news module to automically forward a new post to an email address, possibly in html format?
Last edited by swarfega on Mon Aug 20, 2012 6:46 pm, edited 1 time in total.
staartmees
Power Poster
Power Poster
Posts: 1049
Joined: Wed Mar 19, 2008 4:54 pm

Re: Forwarding news module posts to an email address

Post 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
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

Re: Forwarding news module posts to an email address

Post by swarfega »

Thank you, will try this out.
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: Forwarding news module posts to an email address

Post by manuel »

Me too ;)

Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

Re: Forwarding news module posts to an email address

Post 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.)
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

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

Post 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.
Post Reply

Return to “The Lounge”