---
url: 'https://metadrop.net/en/articles/quick-test-email-sending'
title: 'quick test email sending'
author: 'Jorge Tutor'
date: '2017-01-17T10:40:16+00:00'
updated: '2026-06-10T06:59:46+00:00'
type: article
summary: 'Snippets for sending emails from devel/php for quick email layout tests or service availability tests.'
tags:
  - Drupal
  - 'Drupal 7'
  - Mail
published: true
og:
  determiner: Automatic
  site_name: Metadrop
  'image:alt': 'quick test email sending'
  street_address: 'Calle Manuel Luna, 12, 3 Dcha'
  locality: Madrid
  region: Madrid
  postal_code: '28020'
  country_name: España
  email: hola@metadrop.net
  phone_number: '910053180'
schema:
  '@context': 'https://schema.org'
  '@graph':
    -
      '@type': Article
      '@id': 'https://metadrop.net/en/articles/quick-test-email-sending#article'
      name: 'quick test email sending'
      headline: 'quick test email sending'
      description: 'Snippets for sending emails from devel/php for quick email layout tests or service availability tests.'
      about:
        - Drupal
        - 'Drupal 7'
        - Mail
      datePublished: '2013-08-07T08:00:00+0200'
      dateModified: '2026-06-10T08:59:46+0200'
      author:
        '@type': Person
        name: 'Jorge Tutor'
      publisher:
        '@type': Organization
        '@id': 'https://metadrop.net/#organization'
      mainEntityOfPage: 'https://metadrop.net/en/articles/quick-test-email-sending'
    -
      '@type': Organization
      '@id': 'https://metadrop.net/#organization'
      url: 'https://metadrop.net/'
      name: Metadrop
      sameAs:
        - 'https://www.drupal.org/metadrop'
        - 'https://twitter.com/metadrop'
        - 'https://asociaciondrupal.es/partner/metadrop'
        - 'https://www.linkedin.com/company/metadrop'
      logo:
        '@type': ImageObject
        url: 'https://metadrop.net/themes/custom/mdrop_radix/logo-metadrop-500-500.jpg'
        width: '500'
        height: '500'
    -
      '@type': ItemPage
      '@id': 'https://metadrop.net/en/articles/quick-test-email-sending'
      breadcrumb:
        '@type': BreadcrumbList
        itemListElement:
          -
            '@type': ListItem
            position: 1
            name: Home
            item: 'https://metadrop.net/en'
          -
            '@type': ListItem
            position: 2
            name: 'Expert Drupal & Tech Articles'
            item: 'https://metadrop.net/en/articles'
      publisher:
        '@type': Organization
        '@id': 'https://metadrop.net/#organization'
---
 1. [Articles](https://metadrop.net/en/articles)
 
  

# quick test email sending

Wednesday, August 07, 2013

 

 



Snippets for sending emails from devel/php for quick email layout tests or service availability tests.



   



Drupal 7

```php
$my_module = 'foo';
$my_mail_token = 'bar';
$from = variable_get('system_mail', 'info@test.net');
$message = array(
  'id' => $my_module . '_' . $my_mail_token,
  'to' => 'debug@test.net',
  'subject' => 'Test send',
  'body' => array('test'),
  'headers' => array(
    'From' => $from, 
    'Sender' => $from, 
    'Return-Path' => $from,
  ),
);
$system = drupal_mail_system($my_module, $my_mail_token);
// The format function must be called before calling the mail function. 
$message = $system->format($message);
 
if ($system->mail($message)) {
  // Success.
}
else {
  // Failure.
}
```

Drupal 6

```php
  $message['id'] = 'testing';
  $message['to'] = 'address@mail.net';
  $message['subject'] = 'TEST3';
  $message['body'] = 'Body';
  $message['headers'] = array();
  drupal_mail_send($message); 
```



[Drupal](https://metadrop.net/en/articles?text=Drupal)

[Drupal 7](https://metadrop.net/en/articles?text=Drupal%207)

[Mail](https://metadrop.net/en/articles?text=Mail)

 

- Jorge Tutor
    
    CIO