Snippets

Metadrop Send test mail from Devel (Drupal 7)

Created by Jorge Tutor last modified
<?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' => 'Prueba de envío',
  '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.
  echo 'sucess';
}
else {
  // Failure.
  echo 'failure';
}

Comments (2)

  1. Jorge Tutor

    Útil para ver si el servidor de correo funciona, copiar y pegar en devel/php por ejemplo.

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.