Microsoft 365 Email Signature management reddit / selfhosted ---------------------------------------------------------------------- No-Abies6833 · 2023-12-18 18:43 Hello, I'm looking for a self-hosted alternative to CodeTwo or Exclaimer to insert signatures to my employees emails automatically (I'm thinking of contact info signatures and not crypto signatures.. :D), because I don't want to forward all our mails to a third-party provider for privacy reasons I'm curious if you know any tools/scripts - I haven't found any. ---------------------------------------------------------------------- nlsrhn · 2023-12-18 19:28 I wrote a PowerShell script, loaded via a GPO, which generates the HTML signature for Oulook desktop app everytime when a user logs in with data from her/his AD account (name, job position, phone, mobile, etc.). ---------------------------------------------------------------------- adamshand · 2023-12-18 20:58 Out curiosity, how do these work? Do they just copy a signature into Outlook based on AD info? Or are they doing something more complicated so sigs change on the fly? ---------------------------------------------------------------------- AffairesDePiasses · 2023-12-18 21:16 CodeTwo offers quite a bunch of stuff, like different signatures based one whether it's the first email from this sender or not in a conversation, or also based on a keyword (so users can chose their signature by entering a trigger word in their email) or on some attributes of recipients (we have different translations based on our client language, and also some signatures using specific phone numbers and addresses for some clients). You can also have different signatures if you email different people in the same email : for example, if I send an email to a client, ccing my boss and and external party, my client will receive a custom signature with the specific phone line and team email address dedicated to them, my boss will receive my signature with my internal phone number instead of the one for outside callers, and the external party will receive my regular signature. ---------------------------------------------------------------------- adamshand · 2023-12-18 22:11 Wow, that's pretty cool. I assume it's an Outlook plugin? I don't think there's anyway of doing this wiht a normal HTML signature? ---------------------------------------------------------------------- AffairesDePiasses · 2023-12-18 22:44 You can either use the outlook plugin or route your emails through their SMTP server which does all the heavy lifting. We have many users using different technologies, so we went the SMTP server route. But I don't know about any option that would allow doing that with HTML signatures, especially the splitting part. ---------------------------------------------------------------------- adamshand · 2023-12-18 22:51 Interesting, thanks! SMTP server makes sense ... ---------------------------------------------------------------------- nlsrhn · 2023-12-19 05:15 The problem is, and thats what I've experienced, that the HTML web signature looks slightly different than the one in the Oulook desktop client, for whatever reason I can see formatting differences... ---------------------------------------------------------------------- Adam_CodeTwoSoftware · 2023-12-19 14:07 You can use CodeTwo for email signature management without any rerouting. Instead of using the cloud mode, set up the Outlook mode to have signatures added automatically into emails as end users type. Here's [how it works](https://www.codetwo.com/email-signatures/how-it- works). Client-side support for mobiles is [coming soon](https://www.codetwo.com/blog/add-in-for-outlook-mobile-coming- soon/). ---------------------------------------------------------------------- ZAFJB · 2023-12-19 15:56 Can you share a sanitised version of your script please? ---------------------------------------------------------------------- nlsrhn · 2023-12-19 17:00 Sure thing, will see that I find time tomorrow to do so. ---------------------------------------------------------------------- ZAFJB · 2023-12-19 17:54 Thank you ---------------------------------------------------------------------- nlsrhn · 2023-12-20 06:21 `` `# Check for a working network connection to xxx domain first, either over LAN, WiFI on site or via VPN` `# Network gateways for on-site connection` `$gateways = '172.16.1.253','10.200.201.1'` `while (1) {` `# Get a list of network interfaces which have either a gateway assigned (local connection, on-site) or a connected VPN client (with an assigned IP address)` `$x = gwmi -class Win32_NetworkAdapterConfiguration | where { $gateways -contains $_.DefaultIPGateway -or ( $_.ServiceName = 'ftsvnic' -and $_.IPAddress -like '172.18.1.*') }` `# If there is (at least) one available, exit the loop and continue in the script` `if ( ($x | measure).count -gt 0 ) {` `break` `}` `# Wait 30 seconds, then restart loop` `start-sleep -s 30` `}` `# Setting path for logfile` `$logfile = '\\server\logs\signature_deployment.log'` `# Getting Active Directory information for current user` `# This gets the current, logged-in user without the domain prefix - this query is not depending on the installed language of the OS, as it was previously the case.` `$loggedonuser = (((quser)[1] -replace '\s{2,}', ',') -replace '>','').split(',')[0]` `# The complete user info is pulled from Active Directory and stored in an array.` `$user = (([adsisearcher]"(&(objectCategory=User)(samaccountname=$logg edonuser))").FindOne().Properties)` `# If the user is not found in Active Directory exit the script` `if(!$user) {` `"$(get-date -format "yyyy-MM-dd HH:mm:ss") | " + 'Error: User not found in AD' | out-file $logfile -Append` `exit` `}` `# Create the signatures folder and sets the name of the signature file` `$folderlocation = 'C:\\Users\\'+ $loggedonuser + '\\AppData\\Roaming\\Microsoft\\Signatures'` `$filename = "signature"` `$file = "$folderLocation\\$filename"` `# If the folder does not exist create it` `if(!(Test-Path -Path $folderlocation )){` `New-Item -ItemType directory -Path $folderlocation` `}` `# Company name and logo` `$companyName = "Company Name"` `$logo = "https://www.google.com/images/branding/googlelogo/2x/googlel ogo_color_92x30dp.png" # Please note that if you do include a logo it must be located somewhere on the internet that the public has access to, many users upload it to their website.` `# Specify a additional banner in the signature for advertising events, etc.` `$banner = "https://www.company.com/banner.png"` `$banner_width = 600` `$banner_height = 300` `# Get the users properties (These should always be in Active Directory and Unique)` `$firstname = $user.givenname[0] # First Name` `$lastname = $user.sn[0] # Last Name` `$displayname = $user.givenname[0] + " " + $user.sn[0]` `if($user.title.count -gt 0){$jobtitle = $user.title[0]} # Job Title` `if($user.mail.count -gt 0){$email = $user.mail[0]} # Email Address` `if($user.mobile.count -gt 0){$mobile = $user.mobile[0]} else { $mobile = $null } # Mobile number` `if($user.telephonenumber.count -gt 0){$telephone = $user.telephonenumber[0]} # Office number` `if($user.closingsalutation.count -gt 0){$closingsalutation = $user.closingsalutation[0]} else { $closingsalutation = $null } # Closing Salutation` `# Building HTML` `$signature =` `@"` `Build your HTML signature here` `"@` `# Save the HTML to the signature file` `$signature | out-file "$file.htm" -encoding UTF8` `# Build the txt version for none rich text emails` `$signature_txt =` `@"` `Build your text based signature here` `"@` `# Output the text to the signatures folder` `$signature_txt | out-file "$file.txt" #-encoding UTF8` `# Comment: No encoding for .txt signature to display certain characters correctly` `# Create successful log entry and log the script result` `$logentry = 'Signature deployed successfully to user "' + $loggedonuser + '" on computer "' + $env:computername + '" with data [' + $firstname + ', ' + $lastname + ', ' + $jobtitle + ', ' + $email + ', ' + $telephone + ', ' + $mobile + ', ' + $closingsalutation + '] to destination ' + $file` `"$(get-date -format "yyyy-MM-dd HH:mm:ss") | " + $logentry | out-file $logfile -Append` ---------------------------------------------------------------------- ZAFJB · 2023-12-20 13:33 Thanks. How do you tell Outlook to use those specific signature files that the script generates? ---------------------------------------------------------------------- nlsrhn · 2023-12-20 15:18 AFAIK there is unfortunately no reliable way to set a default signature in Outlook desktop - therefore either I set this for the user after deploying a client or send them a short quick guide to set the signature as default for mails. After all its only 3 clicks - the important part is, that the signature gets re-generated each time the user logs in and is populated with the users AD informaton. If you are wondering: In the script there is a custom AD attribute called "ClosingSalutation" which basically defines, which "closing salutation" (Best Regards, Sincerely, etc.) the specific user is using. You might not need this, but as I live and work in Switzerland and we have 4 official languages, this varies depending on the user and the external people, he/she is dealing with. ---------------------------------------------------------------------- ZAFJB · 2023-12-20 15:28 It's the getting Outlook automatically configured part where I am tripping up. I had a rock sold solution for Outlook up to and including 2019. But with 2021/M365 breaks. Worse, it breaks inconsistently. ---------------------------------------------------------------------- nlsrhn · 2023-12-20 15:37 Yeah I was using a software before as well. But since that one got unreliable, I enhanced/implemented this script and it works quite well. Makes global adjustments for the signature and CI-related things very easy to handle.