I have webform, this webform has many of data, was set from user, and others detected by server, so Im create webform mail template for admin and its wrok fine ..

but when I try to send this email to user submission, its will get the same template style for admin, and I dont need it surly ..

what is the way for get email from address field, then send a specific data style ...

Look at my template code:

<h1 style="text-align: center;color: #505050;"><?= check_plain($node->title) ?></h1>

    $x = webform_submission_render($node, $submission, $email, 'html');

<h5 style="color: #505050;">Name: <?php echo strip_tags($x['#submission']->data[1][0]); ?></h5>
<h5 style="color: #505050;">Email: <?php echo strip_tags($x['#submission']->data[2][0]); ?></h5>
<h5 style="color: #505050;">Company: <?php echo strip_tags($x['#submission']->data[3][0]); ?></h5>
<h5 style="color: #505050;">Phone: <?php echo strip_tags($x['#submission']->data[4][0]); ?></h5>
$notes_cart = $x['#submission']->data[5][0];
if(!empty($notes_cart)) {
    echo "<h5 style='color: #505050;'>Notes: ".strip_tags($x['#submission']->data[5][0])."</h5>";

<h5 style="color: #505050;">Items Order From *** for publishing: </h5>
<?php echo $x['#submission']->data[6][0]; ?>

this admin email template, and if you see, I can get email for user submission, but how i can get it, then set own template, and send email to him ..

thanks a lot.

Thanks every Body, Im write a php code for resolve this proplim, and its resolved by add this function to my custom module like this

function custom_anees_multitask_drupal_mail($from = 'default_from', $to, $subject, $message) {
  $my_module = 'custom_anees_multitask';// module name
  $my_mail_token = microtime();
  if ($from == 'default_from') {
    // Change this to your own default 'from' email address.
    $from = variable_get('system_mail', 'My Email Address <example@example.com>');
  $message = array(
    'id' => $my_module . '_' . $my_mail_token,
    'to' => $to,
    'subject' => $subject,
    'body' => array($message),
    'headers' => array(
      'From' => $from,
      'Sender' => $from,
      'Return-Path' => $from,
  $system = drupal_mail_system($my_module, $my_mail_token);
  $message = $system->format($message);
  if ($system->mail($message)) {
    return TRUE;
  else {
    return FALSE;

**then Im go to my webform template & Im set a call to module function like this

custom_anees_multitask_drupal_mail($from, $to, $subject, $message);

Good Luck, and if there other solution, I will be happy to look to it. Best Regards,**

  • Why you are writing your custom code to send mail? Can't you use webform's default mail? – Sumit Madan Dec 7 '14 at 14:27
  • no, I can send it, but the default mail is used for send to admin, and other listing of emails, but this code only for user thats was submission, this way may to be customize template style for user... – Anees Hikmat Abu Hmiad Dec 7 '14 at 16:37
  • Default template/ mail was used to admin, auth user Custom mail, will send to email address in from submission – Anees Hikmat Abu Hmiad Dec 7 '14 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.