8

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

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

1
  • 3
    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
14

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.

3
  • 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
    Jan 23 '20 at 19:26
  • You can edit the C:\inetpub\mailroot\Badmail*.bad file to manually remove the delivery failure notification portion of the message as shown by Ashley's response below. Instead of PowerShell, open the file and look for the second "From:". Delete everything before but not including the second "From:" Mar 9 '20 at 16:24
6

Create a batch file.

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

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
-1

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

rename *.* *.

2
  • This comment is missing the movement of the file to the correct folder to resend the message. Mar 9 '20 at 16:26
  • This would have been a valid comment, but not a valid answer. Also... the command should be "rename *.bad *." so it doesn't strip the extension from .nbr files.
    – SamErde
    Mar 31 '20 at 18:11
-2

Drag and drop them in the pickup folder.

3
  • 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.