Wednesday, May 22, 2019

Emails going into Draft in a On-premises environment

The problem

You are using OWA or outlook to send your emails (your mail server is an on-premises Exchange server) and all the emails are going into the Draft folder of the user.

The Solution

1. Check the Local services using the Services.msc or services console to make sure that all the exchange servers are set to automatic and are running.

https://msexperttalk.com/exchange-2013-email-stuck-in-draft/ https://www.exchangeitpro.com/2016/06/13/exchange-server-2013-components-in-an-inactive-state/ https://gallery.technet.microsoft.com/exchange/SetExchangeComponentToActiv-874bcd4b

a. Open a Powershell for exchange or simple powershell with administrative privilegies (using Run as Administrator):

 

b. Run my script from technet at https://gallery.technet.microsoft.com/office/What-is-the-size-of-my-0e1993a7 to check Database (.EDB file) and and Logs size in the server

The correct way to run the script will be as follows

#Change Executionpolicy,
Set-ExecutionPolicy unrestricted
#Run the script (move to the folder where the script is downloaded) 
#Ex: in the downloads of the user 'joseo'
cd "C:\Users\joseo\Downloads"
.\ExchangeDBnLogsize.ps1

You will get something like this:

Note: Please Do not modify the edgetransport.exe.config file, it's a bad practice, and it's just a workaround NOT a solution

 

2. Enable circular logs on the Exchange Server databases

The Easiest way to check if your server has enabled or not this feature, open an exchange PowerShell console and run:

#mail server name (On-premises exchange)
$smtpServer= "mail"
#email from can exists or not onprem
$from = "abc@xyz.com"
#to email (must exists, so you can receive the email)
$to = "jose@domain.com"
$event =Get-EventLog -Log "MSExchange Management" | Where{$_.Message -Like "*Enable-Mailbox*"} | select -first 1 

if($event){
    $MailBodyString= $event | ConvertTo-Html 
    #WE CAN'T ATTACH THE FULL THML INTO THE FILE DIRECTLY SO WE NEED TO USE THE TEXT IN THE MIDDLE OF THE  AND 
TAGS WHICH IS DONE USING REGEX #all the results are dump into a table tags so we extract those. $regex = new-object regex('(?s)(< table>(.*)<\</table>)', ([System.Text.RegularExpressions.RegexOptions]::Compiled -bor [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)) $MailBodyAsHtml = $Regex.Match($MailBodyString).VALUE Send-MailMessage -From $from -To $to -Subject "New Account created" -Body $MailBodyAsHtml -SmtpServer $smtpServer -BodyAsHtml }

 

And that's it!, thank you for reading

#when you got the results just return the executionpolicy #(when you finished working with powershell scripts, as a good practice ) Set-ExecutionPolicy remotesigned

Please consider to donate and thank you very much for reading this.

No comments:

Post a Comment