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();
  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>
        <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">

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
    Why not using Webforms? – saadlulu Sep 17 '12 at 8:40

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 = 'user@example.com';
  $message = drupal_mail('example', 'notice', $to, $language, $params, FALSE);
  // Only add to the spool if sending was not canceled.
  if ($message['send']) {

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.