Hello Kaj,
The condition if ($from -eq $NULL) will not work because it is checking a string for being empty. You need to use the following code instead:
if ([System.String]::IsNullOrEmpty($from))
Also, as we can see, the log message that will be added to the execution log contains the %mail% value reference. It will always resolve into an empty value as the message is added only when the target user has no email address. Most probably, you wanted to add the user Full Name to the message. In this case, you need to use value reference %fullname%.
The rest of the script looks correct and should work just fine.