1

I have a block module that looks like this:

enter image description here

Created in the following way:

function VL_newsletter_signup_block_info() {
  $blocks['my-block-id'] = array(
    'info' => t('Enjoy Stories? - Newsletter Signup'),
  );
  return $blocks;
}

/**
 * Implementation of hook_block_view().
 */
function VL_newsletter_signup_block_view($delta='') {
  $block = array();
  switch ($delta) {
    case 'my-block-id':
      //$block['subject'] = t('Block Name');
      $block['content'] = VL_newsletter_signup_contents();
      break;
  }
  return $block;
}

/**
 * custom html block
 * @return string
 */
function VL_newsletter_signup_contents() {
  return '<div class="col4 stories nobile">
    <h2>Enjoy stories?</h2>
    <h3>Sign up to recieve regular news</h3>
    <form>
        <input type="text" name="first" placeholder="First name">
        <input type="text" name="last" placeholder="Last name">
        <input type="email" name="email" placeholder="Email" >
        <input class="send" type="submit" name="submit">
    </form>
    </div>';
}

At the moment my form is static HTML as can be seen, but I plan to use Drupal Form API to render it. My question is: on pressing send, how can I email the form data to a designated admin email address. Can I use triggers somehow or is there another function in Drupal API that could achieve this?

1
  • 1
    Why not using Webforms?
    – saadlulu
    Commented Sep 17, 2012 at 8:40

1 Answer 1

2

You can use drupal_mail() function to send the mail data. You can also use HTML Mail module to integrate nice email templates.

I have shown drupal_mail() function.

$params = array('current_conditions' => $data);
  $to = '[email protected]';
  $message = drupal_mail('example', 'notice', $to, $language, $params, FALSE);
  // Only add to the spool if sending was not canceled.
  if ($message['send']) {
    example_spool_message($message);
  }
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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