LuxCal Forum

The place for questions, suggestions and news about the LuxCal Event Calendar

User:   Password:   Remember Me?   
LuxCal Forum / General / Support / How to send mail always in * days before event?
Posted:  04 Feb 2012 03:19
Trying to make a sort of mail subscription to notify subscribers about upcoming events (in 2 days before an event or weekly to send closest 7 days, as it will be planned in CRON tasks).

I`ve made a new email list, and changed my user`s email in profile on that list, so I should not change my email every time I am adding an event. And, maybe, it is possible to make a CRON task, to notify one or many emails about upcoming events (dayly or weekly) independently from data set in event info?
Posted:  04 Feb 2012 21:51
This should be possible. You could copy the notify.php script and adapt it to your needs.
In this new script, you should for instance:
- retrieve from the database all events which are due between today and today + 7 days
- decide somewhere whether a notification email should be sent 2 days or 7 days before the event is due
- decide for each retrieved event if an email should be sent
- send an email to all destinations in your email list

Thereafter you should add this new "notification 2" script to the lcalcron.php script to ensure it will be run once a day.
Hope this helps.
Posted:  06 Feb 2012 13:21
email should be sent for every event. Notification will be sent every Thursday or Friday and will have events for Friday till Sunday (or next Sunday, didn`t decide yet).

I plan to make a separate CRON task for it and start it once a week.

Tried to modificate notify.php and i`ve got one mail per one event. Is there possible to make one mail for all listed events?

I`ll make further experiments, but will be pleased for your comments.
Posted:  06 Feb 2012 13:45
I think I need to encapsulate "function 'notify'" somewhere in unrepeated function, but I cannot get it how :(
Posted:  06 Feb 2012 22:02
Hi there,
Concerning your email before the last one:
To have a separate cron job, which runs once a week, sounds fine to me.

I don't know how you would like to send one mail for all listed events? All events have a different content I assume, and therefore cannot be combined.
Posted:  06 Feb 2012 22:13
maybe collect total result in  one $message, adding new strings on every iteration and when iterations are finished start "mail" command
Posted:  06 Feb 2012 23:21   Last Edited By: Roel B.
Ah, now I think I understand what you mean. Rather than sending several emails (one for each event) to the same destination, you would like collect all emails for the same destination and then send just one email with all events at the same time.

Is this correct?
This should be possible, but it will require quite a bit of juggling in the notify.php script. Like you said, while processing all events the events for the same destination should be concatenated (added to each other) and only after all events have been processed the emails should be sent.