[development] Send Contents of new node by email (2nd attempt)
Ernst Plüss
ernst.pluess at gmail.com
Thu Jan 28 19:30:14 UTC 2010
I was thinking (and trying) about rules as well. But I need some logic which
evaluates the mail address in between. Running my own action would work of
course.
After all I installed mimemail and token and set up a little form so
administration is easier for me. So my code looks like below now and does
what i want.
Thanks for all the help!
if (!module_exists('mimemail')) {
watchdog('zuweisung', t('Module mimemail is not installed. Unable to
send emails.'), NULL, 'Critical');
return;
}
$sender = variable_get('site_mail', NULL);
$recipient = variable_get('zuweisung_intake_mail_adr', NULL);
$subject = token_replace(variable_get('zuweisung_intake_mail_subject',
NULL), 'node', $node);
$body = token_replace(variable_get('zuweisung_intake_mail_contents',
NULL), 'node', $node);
mimemail($sender, $recipient, $subject, $body);
$sender = variable_get('site_mail', NULL);
$recipient = $node->field_zuw_email[0]['email'];
$subject = token_replace(variable_get('zuweisung_zuweiser_mail_subject',
NULL), 'node', $node);
$body = token_replace(variable_get('zuweisung_zuweiser_mail_contents',
NULL), 'node', $node);
mimemail($sender, $recipient, $subject, $body);
2010/1/28 Klaus Purer <klaus.purer at gmail.com>
> Hi,
>
> On 28/01/10 11:02, Ernst Plüss wrote:
> > I need a solution which sends the email right after the node has been
> > created (30-60 Seconds delay would be ok).
> >
> > I had a quick look at the rules scheduler code. Unfortunately it's not a
> > real timer solution. It just wirtes a record to the db. The next time
> cron
> > is run all sceduled rule sets which have expired are executed. I think
> it's
> > not a good idea to call cron every 60 Seconds.
>
> You can do it with the rules module, but you won't need rules scheduler.
> Just use the event "After saving new content" and the action "Send a
> mail to an arbitrary mail address".
>
> If you have installed the token module, you can use token placeholders
> in the mail text, like content author or other properties of the content.
>
> --
> Klaus Purer
> This E-Mail contains a digital signature and can be verified with this
> PGP|GPG Public Key: http://web.student.tuwien.ac.at/~e0426223/key/kp.asc<http://web.student.tuwien.ac.at/%7Ee0426223/key/kp.asc>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100128/a1bb42a0/attachment.html
More information about the development
mailing list