Posted on

Diagnosing “savemail: cannot save rejected email anywhere”

We recently ran into this message on one of our development servers.   There are a number of reasons this may happen and finding the right solution means finding the cause of the error.  These steps will help you isolate the cause of the error so you can start tracking down the proper solution.  In our case an errant application was not sending the from: field in the mail header thus causing the message to fail the basic mail format checks.

Checking Aliases

First make sure you have the following entries in /etc/aliases:

# Basic system aliases -- these MUST be present
MAILER-DAEMON:    postmaster
postmaster:    root

If these entries are present, try running these commands:

# sendmail -bv MAILER-DAEMON
# sendmail -bv postmaster

It should come back immediately with a message like the one below:

postmaster@cybersprocket.com... deliverable: mailer relay, host [127.0.0.1], user postmaster@cybersprocket.com

If it does not, rebuild the aliases database by running the newaliases command:

# newaliases

Forcing A Resend With Logging

Failed messages remain in the mail queue directory for examination by the system administrator. Sendmail renames the header of the queued message from qf* to Qf*, making it easy to identify these messages in your mail queue.  You can easily list the failed messages with the following mailq command:

# mailq -qL

To diagnose, locate the offending message ID in the log (/var/log/maillog) or by using the mailq -qL command.

Rename the matching Qf<message_id> file to qf<message_id>, and execute the following command:

sendmail -v -qI<message_id> -d11

The Problem Revealed

You should now have a detailed log file indicating what the source of the problem was.  In our case we see the From: line in the mail header is blank:

>>> MAIL From:<>
501 Syntax error in arguments
Data format error

Hope that helps. Good luck!

Posted on

Configuring log4net with VS2010 and .Net 4.0

We need your help!


Cyber Sprocket is looking to qualify for a small business grant so we can continue our development efforts. We are working on a custom application builder platform so you can build custom mobile apps for your business. If we reach our 250-person goal have a better chance of being selected.

It is free and takes less than 2 minutes!

Go to www.missionsmallbusiness.com.
Click on the “Login and Vote” button.
Put “Cyber Sprocket” in the search box and click search.
When our name comes up click on the vote button.

 

And now on to our article…

After spending a few hours this morning trying to get log4net working with a project, I decided to share my findings.   I chased a lot of dead-ends for what wound up being a fairly simple solution.  Here is a quick article to save both myself, and maybe you, some time in the future.

Get Log4Net

Go to http://logging.apache.org/log4net/ and get the latest version.    Add the project file to your solution.   Then right-click that project, choose the build tab and…

Step 1: Set the log4net conditional compilation symbols replacing NET_1_0 with NET_4_0.

Log4Net Requires Full .Net Access

That means you cannot use “client profile”.  log4net was originally written to log web services.  As such it expects to have a lot of server-side classes available, even though most of those classes are never instantiated.

Step 2: Build  Your Application & The Log4Net component under .Net 4.0, not .Net 4.0 Client Profile

Make Log4Net Less Secure

The .Net 4.0 assemblies are more secure by default.  You need to override this.   As I’m not a .Net development guru I’m not really certain what the differences mean, but Google is your friend (and mine) here, so if you are concerned (and you should be before launching a public app) then search the Internet to find out what this mean. In the meantime…

Step 3: Make log4net assembly less secure, add
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
to the log4net AssemblyInfo.cs file.

Done.

That’s it, the first steps for getting a log4net component into your application.   Now you can follow some of the development & deployment document on the Apache site:

http://logging.apache.org/log4net/release/manual/configuration.html