Sieve-Example:HTML Autoresponder: Difference between revisions

From AAISP Support Site
mNo edit summary
(syntax!)
 
(13 intermediate revisions by one other user not shown)
Line 1: Line 1:
Sometimes you may want to sent an autoresponder, eg an out of office, or an automatic reply for some other reason as a HTML message.
Sometimes you may want to sent an autoresponder, eg an out of office, or an automatic reply with further information, but you want to specifically send html for some reason.


You can use the following as an example, to format the response:
You can use the following sieve code as an example:


<syntaxhighlight>
<syntaxhighlight lang=sieve>
require ["vacation","variables"];
require ["vacation","variables"];
require ["vacation","variables"];
# rule:[html auto responder reply]
# rule:[html auto responder reply]
Line 11: Line 12:
set "subject" "${1}";
set "subject" "${1}";
}
}
vacation
vacation :subject "Automatic reply with HTML information. Re ${subject}"
:subject "Automatic reply with HTML information. Re ${subject}"
:mime text:
MIME-Version: 1.0
:mime "MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Transfer-Encoding: 7bit
Line 23: Line 24:
</body>
</body>
</html>
</html>
;
";
}
}
</syntaxhighlight>
</syntaxhighlight>


'''See below how to add this via Roundcube.'''


This will:
This will:
* Match any incoming email
* Match any incoming email to the mailbox
* Put the subject line in to a variable
* Put the subject line in to a variable
* Reply back to the sender with a modified subject line
* Reply back to the sender with a modified subject line
* Include HTML in the email
* Include HTML in the email


=== Example reply:===
==Editing this in Roundcube==
[[File:Html-reply.png|border]]
Roundcube has a 'wizard' or WYSIWYG editor, that allows you to create filters using a form. However, for this do you can't use this editor, you have to edit the sieve script by hand, Roundcube lets you do this though.

In Roundcube, go to Settings, Filters.

You can create a filter if you've not got one, but then you need to edit it manually - you click the cog at the bottom, and click 'edit filter set'


===Improvements / Notes===
You can paste in the script above.


More can be done with this script, eg
You can edit the HTML, if you add any quotes (") in the HTML then you will need to escape it by using: \"
*you can modify it to include a multipart reply (HTML and plain text)
*you can restrict the reply to only once a day per sender, by adding :days 1 under :vacation
* You can edit the subject line and the HTML to your liking, if you add any quotes (") in the HTML then you will need to escape it by using: \" - adding images is probably going to be problematic, don't bother trying! Inline css will probably be ok.
*This WON'T include any signature, but you can add what ever HTML you like.


=Editing this in Roundcube=
Clicking save should say that it's updated, if you get errors, then the syntax you have won't be correct, but the example above works.
Roundcube has a 'wizard' or semi-WYSIWYG editor, that allows you to create filters using a form. However, for this example it won't understand all the syntax so you can't use this editor, you have to edit the sieve script by hand, Roundcube lets you do this though.


# In Roundcube, go to Settings, Filters.
This WON'T include any signature, but you can add what ever HTML you like.
# You may already have a 'Filter set' called roundcube, that's fine.
# At the bottom of the 'filter set' collumn, click the cog icon, and then 'Edit filter set'
# You can paste in the script above.
# Clicking save should say that it's updated, if you get errors, then the syntax you have won't be correct, but the example above works.


If you later edit the filter with Roundcube be sure to use the 'edit filter set' link as otherwise the code will get altered and not work.
If you later edit the filter with Roundcube be sure to use the 'edit filter set' link as otherwise the code will get altered and not work.

Latest revision as of 23:06, 28 November 2022

Sometimes you may want to sent an autoresponder, eg an out of office, or an automatic reply with further information, but you want to specifically send html for some reason.

You can use the following sieve code as an example:

require ["vacation","variables"];
require ["vacation","variables"];
# rule:[html auto responder reply]
if true
{
    if header :matches "subject" "*" {
      set "subject" "${1}";
    }
    vacation
    :subject "Automatic reply with HTML information. Re ${subject}" 
    :mime "MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
<!DOCTYPE html><html><head></head>
<body>
<h1>Thank you</h1>
<hr>
<b>I am away</b>
</body>
</html>
";
}

See below how to add this via Roundcube.

This will:

  • Match any incoming email to the mailbox
  • Put the subject line in to a variable
  • Reply back to the sender with a modified subject line
  • Include HTML in the email

Example reply:

Html-reply.png

Improvements / Notes

More can be done with this script, eg

  • you can modify it to include a multipart reply (HTML and plain text)
  • you can restrict the reply to only once a day per sender, by adding :days 1 under :vacation
  • You can edit the subject line and the HTML to your liking, if you add any quotes (") in the HTML then you will need to escape it by using: \" - adding images is probably going to be problematic, don't bother trying! Inline css will probably be ok.
  • This WON'T include any signature, but you can add what ever HTML you like.

Editing this in Roundcube

Roundcube has a 'wizard' or semi-WYSIWYG editor, that allows you to create filters using a form. However, for this example it won't understand all the syntax so you can't use this editor, you have to edit the sieve script by hand, Roundcube lets you do this though.

  1. In Roundcube, go to Settings, Filters.
  2. You may already have a 'Filter set' called roundcube, that's fine.
  3. At the bottom of the 'filter set' collumn, click the cog icon, and then 'Edit filter set'
  4. You can paste in the script above.
  5. Clicking save should say that it's updated, if you get errors, then the syntax you have won't be correct, but the example above works.

If you later edit the filter with Roundcube be sure to use the 'edit filter set' link as otherwise the code will get altered and not work.

Roundcube-sieve-html-responder.png