You are here

function sendgrid_integration_test in SendGrid Integration 8.2

Same name and namespace in other branches
  1. 8 sendgrid_integration.admin.inc \sendgrid_integration_test()
  2. 7 sendgrid_integration.admin.inc \sendgrid_integration_test()
1 string reference to 'sendgrid_integration_test'
SendGridTestForm::getFormId in src/Form/SendGridTestForm.php
Returns a unique string identifying the form.

File

./sendgrid_integration.admin.inc, line 11
Provides a form to send a test email through Sendgrid.

Code

function sendgrid_integration_test() {
  $form = [];
  $defaults = variable_get('sendgrid_integration_test_defaults', [
    'to' => variable_get('site_mail', 'user@example.com'),
    'subject' => 'Test Email from SendGrid Module',
    'body' => [
      'value' => 'Test Message for SendGrid.',
    ],
    'fromname' => '',
    'toname' => '',
    'replyto' => '',
  ]);
  $defaults['body']['format'] = filter_fallback_format();
  $form['fromname'] = [
    '#type' => 'textfield',
    '#title' => t('From name'),
    '#default_value' => $defaults['fromname'],
    '#maxlength' => 128,
  ];
  $form['to'] = [
    '#type' => 'textfield',
    '#title' => t('To'),
    '#default_value' => $defaults['to'],
    '#maxlength' => 128,
    '#required' => TRUE,
  ];
  $form['toname'] = [
    '#type' => 'textfield',
    '#title' => t('To Name'),
    '#default_value' => $defaults['toname'],
    '#maxlength' => 128,
  ];
  $form['replyto'] = [
    '#type' => 'textfield',
    '#title' => t('Reply-To'),
    '#maxlength' => 128,
    '#default_value' => $defaults['replyto'],
  ];
  $form['subject'] = [
    '#type' => 'textfield',
    '#title' => t('Subject'),
    '#default_value' => $defaults['subject'],
    '#maxlength' => 128,
    '#required' => TRUE,
  ];
  $form['include_attachment'] = [
    '#title' => t('Include attachment'),
    '#type' => 'checkbox',
    '#description' => t('If checked, the Drupal icon will be included as an attachment with the test email.'),
    '#default_value' => TRUE,
  ];
  $form['body'] = [
    '#type' => 'text_format',
    '#title' => t('Body'),
    '#rows' => 20,
    '#default_value' => $defaults['body']['value'],
    '#format' => $defaults['body']['format'],
    '#required' => TRUE,
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => t('Send test message'),
  ];
  return $form;
}