Reputation: 2993
I am using hMail Interop library from .net code to communicate with my email server. Is it possible to set catch all email server from that library?
Upvotes: 0
Views: 1692
Reputation: 468
The Interface Domain specifies the property Postmaster. This is a string that holds the address of an account that should be used as the catch-all for the domain.
Example:
public void SetDomainCatchAll(String domainName, String catchAllAddress)
{
String myUserName = "MyUserName";
String myPassword = "MyPasword";
// get hMailServer application instance
Application app = new ApplicationClass();
app.Authenticate(myUserName, myPassword);
// check that domain and account exist
Domain domain = app.Domains.get_ItemByName(domainName);
Account account = domain.Accounts.get_ItemByAddress(catchAllAddress);
// set postmaster and save changes
domain.Postmaster = account.Address;
domain.Save();
}
Of course this is very rough code with no error checking or anything, but I hope it shows you what you want to know. If you use the Administration Program afterwards you can check on the advanced tab of the domain entry that the catch-all address has been successfully set.
I tested this on hMailServer version 5.4-B1950.
Upvotes: 1