1

I have drupal site in that ,i want to send a email to charities when donor post a donation..,and i want to send a email notification to charities,so how i send email using drupal7

$message = array(
  'to' => '"'. addslashes(mime_header_encode('new donation')) .'" <test@example.com>';
  'subject' => t('Example subject'),
  'body' => "<html><head></head><body><b>Hi user! a donor added a new donaion! So please     check the site for more infomation!<br/>Thanks,<br/></b></body></html>",
  'headers' => array(
          'From' => 'test@test.org',
          'MIME-Version' => '1.0',
          'Content-Type' => 'text/html;charset=utf-8',),
);

drupal_mail_send($message);
  • 1
    "when the donor posts a donation" can you explain more about it. The donation is a node or your customized data in your own table. – Stone Vo Mar 21 '13 at 5:02
  • actulty donation is a node and alos a custom content type,but i have develop that part i want to send the email and i want kown, – wordpresrox Mar 21 '13 at 5:11
  • 1
    Ok i'll write down the answer for you now. – Stone Vo Mar 21 '13 at 5:16
  • Have you solved your problems yet ? – Stone Vo Mar 21 '13 at 7:04
7

First you must enable the following modules:

1. Mailsystem module http://drupal.org/project/mailsystem
2. Mimemail module http://drupal.org/project/mimemail (it contains the mail actions and sending mail function) or you can use htmlmail module http://drupal.org/project/htmlmail
3. Rules module http://drupal.org/project/rules

After that you will do some steps:

1. Create new rule in admin/config/workflow/rules/reaction/add and select the "React on event" is "After saving new content".
2. Add a condition. Choose Node (Content is of type) for condition and choose your custom content type in the "Content types" list box.
3. Add another condition. Choose User(User has roles()). Choose data selector is "node:author" and choose the role of donor.
4. Add the action. Choose System (Send HTML email). You'll change the To, CC, subject, content here.
5. Try to test that.

Be sure that you can send email using your system. If you use the htmlmail module. It will have the send test email in its setting.

1

You may use Rules module to send email automatically.

The rules module allows site administrators to define conditionally executed actions based on occurring events (known as reactive or ECA rules).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.