I am trying to send an email with a small html form of hidden fields and a submit button. I have been piecing this together from several very incomplete answers and documentation sources that take several approaches to this but no answer so far has worked for me (so please do not mark this as a duplicate).
I have a module, my_module, and in the my_module.module file I have the following hook.
function ten_sixteen_mail($key, &$message, $params) {
if (isset($params['subject'])) {
$message['subject'] = $params['subject'];
}
if (isset($params['body'])) {
$message['body'][] = $params['body'];
}
if (isset($params['headers']) && is_array($params['headers'])) {
$message['headers'] += $params['headers'];
}
}
Elsewhere in my_module.module I send an email with the following code. I am getting the email, but without the form and button html, only the
text.
$to = "[email protected]";
$subject = "This is an email subject";
$body = "<p>Here is some text.</p>";
$body .= '<form name="someform" action="https://www.example.com/somepage" method="post">';
$body .= '<input type="hidden" name="somecode" value="' . $somecode . '" />';
$body .= '<input type="hidden" name="something" value="' . $something . '" />';
$body .= '<input type="submit" style="padding: 10px; background-color: #d42c2c; border: 2px solid #cccccc;" value="Click This" />';
$body .= '</form>';
$params = array(
'headers' => 'Content-type: text/html',
'subject' => $subject,
'body' => $body,
);
$message = drupal_mail("my_module", "my_module", $to, language_default(), $params, "[email protected]");
I have Mail System and Mime Mail installed and enabled.
I'm pretty confused about the config options for both modules. For Mail System I have set the 'theme to render the emails' to my custom theme, though I really don't require any theme-ing of the email it was not an option to disable this.
I have created a new module and key setting with the key my_module for the module my_module.
Mime Mail is set to use the Full HTML Email format.
What am I doing wrong that is preventing my html form from coming through in the email?