Can someone please point me in the right direction.
Is there any way to output the plain text sent in the email to something like the output sent to the screen when completing the form.
Please, not just the code needed, but where to put the code. e.g. put this code in this file in this folder.
Many thanks.

Also, great module.

Comments

quicksketch’s picture

Is there any way to output the plain text sent in the email to something like the output sent to the screen when completing the form.

Could you clarify? You want to change the output of the e-mail or you want to show the e-mail output when completing the form?

taxicab221’s picture

I would like to change the output of the email that I receive.

I have copied the file webform-mail-tpl.php to the current theme folder as instructed by the file info : -

* Customize the e-mails sent by Webform after successful submission.
*
* This file may be renamed "webform-mail-[nid].tpl.php" to target a
* specific webform e-mail on your site. Or you can leave it
* "webform-mail.tpl.php" to affect all webform e-mails on your site.

*

No change to the email output!

Have read on another post about including a function to change the email headers, but being a newbee, did not know where (which file), to put this function.

I hope this clarifys what I am trying to achieve.

I know this might sound like hand holding, but if we (newbees) are to try to understand how things work, i/we need to be pointed in the right direction.

Fantastic module by the way quicksketch.

Update

Thanks for the quick response

hedley’s picture

I've been trying to edit webform-mail.tpl.php to make the output more easily readable and I'm getting nowhere either!

What I've been trying to do (I thought) seemed fairly simple, just break up the fieldsets in the email by adding a space or divider or some kind, but I just can't seem to find the right syntax to print each fieldset array.

Anyway It would be great if either the default webform-mail.tpl.php had a nicer looking output, or if there was a additional form component for email formatting which was hidden by default in the form display maybe?

guislutavo’s picture

I hope this could be useful, or if not, correct me if I'm wrong. In the webform-mail.tpl.php I have replaced the second php code between brackets whith this (sorry, is in spanish, but you will understand the code):

CONSTANCIA DE INSCRIPCIÓN

<?php print $form_values['submitted_tree']['name']; ?>


Datos Inscripción
Fecha de inscripción:	<?php print $form_values['submitted_tree']['date']; ?>

Costo Inscripción:	$ <?php print $form_values['submitted_tree']['cost']; ?>

So, the email show the following:

 CONSTANCIA DE INSCRIPCIÓN
John Mendes

Datos Inscripción
Fecha de inscripción:   March 19, 2009 - 12:32
Costo Inscripción:      $ 120

This change all the e-mails. I still have some problems with the tabulations. The endline never works so I put an extra line between any sentence and it fixes. There is another 2 forms of print the text:

<?php print 'Fecha de inscripción:   '.$form_values['submitted_tree']['date'] ?>
<?php print t('Fecha de inscripción:	' , $form_values['submitted_tree']['date']) ?>

For the fieldsets and the hidden components you must call the function as:

<?php print $form_values['submitted_tree']['fieldset_name']['component_name']; ?>
taxicab221’s picture

UPDATE

I first copied the file 'webform-mail.tpl.php into my theme folder and renamed it to webform-mail-[nid].tpl.php.

I then started to edit this form, using the first 6 php statements as below

<?php print t('Submitted on @date', array('@date' => format_date(time(), 'small'))) ?>

<?php if ($user->uid): ?>
<?php print t('Submitted by user: @username [@ip_address]', array('@username' => $user->name, '@ip_address' => $ip_address)) ?>
<?php else: ?>
<?php print t('Submitted by anonymous user: [@ip_address]', array('@ip_address' => $ip_address)) ?>
<?php endif; ?>

From here, i started to build a table to format all the relevant data I wanted to be submitted as below

<h1 style="color:#336633">Declaration of Health &amp; Medical Fitness</h1>
<table width="750" cellpadding="3">
	<tr>
	  <td colspan="3" align="center"><h3>Personal Details </h3></td>
      <td>&nbsp;</td>
      <td colspan="3" align="center"><h3>Doctors Details </h3></td>
  </tr>
	<tr>
		<td width="150" align="right">Forename(s)</td>
	    <td align="center"><strong>:</strong></td>
	    <td width="200"><?php print t($form_values['submitted']['2']) ?></td>
	    <td>&nbsp; </td>
	    <td width="150" align="right"></h1>
	      GP's Name </td>
	    <td align="center"><strong>:</strong></td>
	    <td width="200"><?php print t($form_values['submitted']['14']) ?> </td>
	</tr>
	<tr>
	  <td width="150" align="right">Surname</td>
      <td align="center"><strong>:</strong></td>
      <td width="200"><?php print t($form_values['submitted']['3']) ?> </td>
      <td>&nbsp; </td>
      <td width="150" rowspan="2" align="right" valign="top">Address</td>
      <td rowspan="2" align="center" valign="top"><strong>:<br />
        :</strong></td>
      <td width="200" rowspan="2" valign="top"><?php print t($form_values['submitted']['15']) ?><br /><?php print t($form_values['submitted']['16']) ?></td>
........
<tr>
          <td colspan="4"><strong>Please give details below of any medical condition
              for which you have received treatment in the last 3 years </strong></td>
        </tr>
        <tr>
          <td colspan="4"><?php print t($form_values['submitted']['93']) ?></td>
        </tr>
        <tr>
          <td colspan="4"><hr /></td>
        </tr>
        <tr>
          <td colspan="4">By selecting the I CONFIRM box and submitting this form, I&nbsp;<?php print t($form_values['submitted']['2']) ?>&nbsp;<?php print t($form_values['submitted']['3']) ?>&nbsp;confirm that the answers to these questions are true and accurate to the best of my belief and knowledge. </td>
        </tr>
        <tr>
          <td colspan="4">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="4"><hr /></td>
        </tr>
      </table></td>
  </tr>
</table>

It took a few tests to find all the <?php print t($form_values['submitted']['??]) ?> submitted values I needed, but in the end I now have an email that is formatted into a friendly, readable, printable way

I hope this helps.

guislutavo’s picture

Oh thanks a lot, I was trying to do this but never works... I'll try again.

4kant’s picture

Hi taxicab221,

did you get an HTML-e-mail when sending the submissions?
I get only the source-code (or plain text).

If you do so: How did you make it?

Thanks

4kant

Friso D’s picture

Thanks guislutavo and taxicab221 for your help,
I had been looking around for some time for the right PHP code to make certain form values appear in my confirmation email, but to no avail. Thanks for helping me out.

taxicab221, I have the same issue 4kant has; when I put the PHP variables into HTML i receive an unformatted HTML mail in return.
Is there some code I should put in front to push the mail editor to create the rich text? Is it a setting in webform?
I tried looking on PHP.net but couldn't find anything.

Thanks for the great help you are all providing, hope to find a way out on this.

Friso D

taxicab221’s picture

Sorry for not getting back to you all sooner, been away.

Check out this link

http://drupal.org/node/270472

I seem to remember I had to insert the code into the template file.

Dave

Friso D’s picture

Hello Dave,
thanks for the hint. I inserted the code into the template file and it works just fine.

Ciao,
Friso

quicksketch’s picture

Status: Active » Closed (fixed)
ShannonK’s picture

I'm sorry I'm such a novice - I don't understand the above instructions. I love this module (Webform) and we are currently using it successfully. I have conditional email recipients up and working as well...what a fantastic feature! But I've been asked to make the emailed results of the form look a little better. What would be great is if I could have the form results in a different font color than the form questions. I followed the instructions and copied the webform-mail.tpl.php file to my themes directory, but I don't know what to do from there. Once I edit it, do I leave it there? Is it even possible for me to change the font color of the user input (form results) in the email?

Thanks in advance - and great module!