Trying to get newlines on form submission for an email sent. For some reason no matter what I try this isn’t happening:
function MY_MODULE_form_submit($ form, &$ form_state) { $ body = array(); $ valid_email = $ form_state['values']['email']; $ form_state_array = MY_MODULE_get_fields_this_step($ form_state); $ data = ''; foreach ($ form_state_array as $ key=>$ value){ $ data = $ key.' : '.$ value . "<br />\r\n"; $ body[] = $ data; } $ from = 'andy@example.com'; $ to = $ valid_email; $ params = array( 'body' => $ body, 'subject' => 'test', 'headers' => array( 'Bcc' => 'andy@example.com', ) ); if (drupal_mail('MY_MODULE', 'quote_info', $ to, language_default(), $ params, $ from, TRUE)) { drupal_set_message('Check your email for your quote!.'); } else { drupal_set_message('There was an error sending your quote'); } }
I’ve tried disabling all third party mail modules and yet I’m still having this problem. As you can see, I’m trying both normal line breaks as well as
.
I’ve also got this:
function MY_MODULE_mail($ key, &$ message, $ params) { $ headers = array( 'MIME-Version' => '1.0', 'Content-Type' => 'text/html; charset=UTF-8;', 'Content-Transfer-Encoding' => '8Bit', 'X-Mailer' => 'Drupal' ); foreach ($ headers as $ key => $ value) { $ message['headers'][$ key] = $ value; } $ message['subject'] = $ params['subject']; $ message['body'] = $ params['body']; }
What could be going on? This is happening irrespective of mail client.