7

We have IIS setup as an SMTP relay. A relay security error caused the outbound emails to be delivered to the badmail folder for the IIS SMTP Service.

Is there any standard method for attempting to retry delivery of these emails?

  • 2
    I create a simples C# program to remove bad header and rename .BAD file to .EML It work for me. Maybe work too to someone. github.com/zogbi/BadToPickup – user302309 Jul 30 '15 at 13:54
12

According to Microsoft support:

To replay the messages that are located in the Badmail folder, follow these steps:

  1. Stop the SMTP service.

    1. Open IIS Manager.

    2. Right-click Default SMTP Virtual Server, and then click Stop.

  2. Copy all the files that are located in the Badmail folder and that have the .bad file name extension. Then, paste these files to the Pickup folder.

  3. Delete the .bad file name extension from all the .bad files that are located in the Pickup folder.

  4. Start the SMTP service.

    1. Open IIS Manager.

    2. Right-click Default SMTP Virtual Server, and then click Start.

  5. Verify that the messages were delivered.

  • That MS KB article is apparently no longer available. Wonderful. – wfaulk Apr 12 '18 at 15:58
  • Note that this re-sends the delivery failure notification, not the original message. – Michael - Where's Clay Shirky Jan 23 at 19:26
5

Create a batch file.

@Echo on 
net stop smtpsvc
move x:\inetpub\mailroot\badmail\\*.bad x:\inetpub\mailroot\pickup\\*.
cd\
net start smtpsvc
3

Alternatively, you could use the Powershell script below wonderfully created by our in-house technical guru. It drops the "Delivery Failure" part of the .BAD file and retries the message as if it were the original send.

$INETPUBHome = "C:\inetpub\mailroot"
$BadMail = "$INETPUBHome\BadMail"
$Pickup = "$INETPUBHome\Pickup"

stop-service -Name SMTPSVC

foreach ($f in Get-ChildItem -Path $BadMail -Filter *.bad) {
    $smpt_body = Get-Content -Path $f.FullName -Raw

    $r = $smpt_body -replace "(?smi)From:[^!]+?^From:", "From:"

    $r | Out-File -FilePath $Pickup\$($f.BaseName) -Encoding ascii

    Remove-Item $f.FullName
}

start-service -Name SMTPSVC
0

You can open a command prompt and navigate to the badmail folder and run the following command to remove extensions on all messages:

rename *.* *.

-1

Drag and drop them in the pickup folder.

  • It will pull out the error message and resend from the *.BAD, *.BDP, or *.BDR files? – catalpa Nov 8 '11 at 13:34
  • I wish it was that easy. Not looking forward to changing the extensions of 30K files. – catalpa Nov 8 '11 at 14:14
  • Hmmm... That worked in Windows 2003... Should have checked what changed since then. – SBWorks Nov 8 '11 at 15:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.