Email 2FA Template
-
Does anyone know if it is possible to edit the emailed 2FA template? I wanted to be able to have it texted to a cell phone but right now it is sending all of the HTML formatting as a text message.
Thanks!!
-
There is not currently a feature to edit the 2FA email, however, you can use the content filter to modify it. You'll first need to enable the option for "System generated messages are sent through the content and spam filters." (Setup | Preferences | Miscellaneous)
Then create a rule similar to the following:
RuleName=Convert To PlainText
uid={f9c716a9-6720-4261-96ac-039c9f3ffcca}
Enable=Yes
ThisRuleCondition=All
ProcessQueue=BOTH
Condition01=X-MDAEMON-DELIVER-TO|contains|AND|@vzwpix.com|
Action01=run a program|"-1,0,0","C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File c:\scripts\RemoveHTML.ps1 -MSGFileName $MESSAGEFILENAME$"The script below can be used to convert the HTML body to plain text.
param( [string]$MSGFileName ) ################################################################################################################################ ################################################################################################################################ ## Remove HTML portion of the email body v 1.0.1 ## ## May 21 2020 ## ## Copyright MDaemon Technologies 2020 ## ## ## ## This script is designed to be ran by the content filter in MDaemon. It accepts the path to a message file as a parameter. ## ## The script loads the passed message using CDO and deletes the HTML portion of the body of the email. ## ## ## ## Here is a sample content filter rule that can be used to call the script: ## ## ## ## RuleName=Remove HTML ## ## Enable=Yes ## ## ThisRuleCondition=All ## ## ProcessQueue=LOCAL ## ## Condition01=body|all message|AND| ## ## Action01=run a program|"-1,0,0","C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass ## ## c:\mdaemon\PowerShell\RemoveHTML.ps1 -MSGFileName "$MESSAGEFILENAME$"" ## ## ## ## ## ## ## ## MDaemon Technologies offers no warranty, provides no support, and is not responsible for any damages that may be arise ## ## from the use of this script. Use at your own risk. ## ## ## ################################################################################################################################ ################################################################################################################################ clear function Get-PrivateProfileString ($Path, $Category, $Key) { ############################################################################# ## ## Get-PrivateProfileString ## ## From Windows PowerShell Cookbook (O'Reilly) ## by Lee Holmes (http://www.leeholmes.com/guide) ## ############################################################################## <# .SYNOPSIS Retrieves an element from a standard .INI file .EXAMPLE Get-PrivateProfileString c:\windows\system32\tcpmon.ini ` "<Generic Network Card>" Name Generic Network Card #> Set-StrictMode -Version Latest ## The signature of the Windows API that retrieves INI ## settings $signature = @' [DllImport("kernel32.dll")] public static extern uint GetPrivateProfileString( string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, uint nSize, string lpFileName); '@ ## Create a new type that lets us access the Windows API function $type = Add-Type -MemberDefinition $signature ` -Name Win32Utils -Namespace GetPrivateProfileString ` -Using System.Text -PassThru ## The GetPrivateProfileString function needs a StringBuilder to hold ## its output. Create one, and then invoke the method $builder = New-Object System.Text.StringBuilder 1024 $null = $type::GetPrivateProfileString($category, $key, "", $builder, $builder.Capacity, $path) ## Return the output $builder.ToString() } function GetRegistryValue($Key, $Name){ if(Test-Path $Key) { $Value = (Get-ItemProperty $Key -Name $Name).$Name } if(!(Test-Path $Key) -or ($Value -eq $null) -or ($Value.Length -eq 0)) { $Base = Split-Path (Split-Path $Key) $Leaf2 = Split-Path $key -Leaf $Leaf1 = Split-Path (Split-Path $key) -Leaf $SysWownode = Join-Path (Join-Path (Join-Path $Base "Wow6432Node") $Leaf1) $Leaf2 if(Test-Path $SysWownode) { Log "The registry key value is empty or does not exist, checking $SysWownode." $Value = (Get-ItemProperty $SysWowNode -Name $Name).$Name if(($Value -eq $null) -or ($Value.Length -eq 0)) { Log "We can't find the registry key values, the script will now stop." exit } else { $Error.Clear() return $Value } } else { Log "We can't find the registry key values, the script will now stop." exit } } else { return $Value } } function Log($string, $color){ if($string -ne $null) { if($global:LoggedScriptStarting -ne "Yes") { $global:LoggedScriptStarting = "Yes" Log "Starting Script run at $CurrentDate.`r`n" } if ($color -eq $null) { $color = "White" } write-host $string -ForegroundColor $color if ($LogFile -ne $null) { $string | out-file -Filepath $LogFile -append } } } function Load-EmlFile ($MSGFileName){ if($MSGFileName -eq "" -or (!(Test-Path $MSGFileName))) { Log "The File name, $MSGFileName, is empty or does not exist. This is a critical error. The script will now exit." exit } $AdoDbStream = New-Object -ComObject ADODB.Stream $AdoDbStream.Type = 1 $AdoDbStream.Open() $AdoDbStream.LoadFromFile($MSGFileName) $CdoMessage = New-Object -ComObject CDO.Message $CdoMessage.DataSource.OpenObject($ADoDBStream,"_Stream") #$AdoDbStream.Close() return $CdoMessage } function Save-EmlFile ($Message, $OutputFile) { Log "Saving updated message to disk as $OutputFile." $Message.GetStream().SaveToFile($OutputFile,2) } $MDINIPath = GetRegistryValue "HKLM:\SOFTWARE\Alt-N Technologies\MDaemon" "IniPath" $LogPath = Get-PrivateProfileString $MDINIPath "Directories" "LogFiles" $CurrentDate = Get-Date $LogFileDate = (Get-Date -Format yyyy-MM-dd) $LogFile = join-path $LogPath "MDaemon-$LogFileDate-Remove-HTML.log" #$MSGFileName = "C:\MDaemon\Queues\Bad\md50000001390.msg" $OutputFile = $MSGFileName #"C:\MDaemon\Queues\Bad\md50000001391.msg" Log "The MDaemon INI path is: $MDINIPath" Log "The Log path is: $LogPath" Log "Loading $MSGFileName" $MSG = Load-EmlFile $MSGFileName $MSGID = $MSG.Fields.Item("urn:schemas:mailheader:Message-ID").Value Log "The message ID is $MSGID." Log "The HTML section of the message body is:" Log $MSG.HTMLBody if($MSG.HTMLBody -ne "") { if($MSG.TextBody -eq "") { Log "The text body was empty, Autogenerating it from the HTML body." $MSG.AutoGenerateTextBody = $true } Log "Removing HTML body part from $MSGFileName" #$MSG.BodyPart.BodyParts.Delete($MSG.HTMLBodyPart) $MSG.HtmlBodyPart.Parent.BodyParts.Delete($MSG.HTMLBodyPart) Save-EmlFile $MSG $OutputFile } else { Log "No HTML body was found. Nothing is being done." } $CurrentDate = Get-Date Log "`r`nEnding Script run at $CurrentDate." Log "----------"If you'd lke to make further adjustments to the body, create another rule that will run after this one and use the Search and replace in the body action of the content filter.