sendEmail "content type"

Hello folks,

I'm sending emails, it works, but I do get a warning in the logs:

com.inductiveautomation.ignition.common.script.JythonExecException: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Incomplete email parameters. You must specify the SMTP host, from, recipient, and content type.

Here's the part responsible for sending the mails, I only modified the fromAddr and subject parameters:

if customer_message is not None:
	system.net.sendEmail(
		smtp = "localhost:25",
		fromAddr = "no-reply@ourcompany.com",
		subject = "mail_subject",
		to = customer_addresses,
		body = customer_message
	)

Comparing the error and those parameters, the only one that is not there is content type. But I can't see any content type parameter in the docs (system.net.sendEmail - Ignition User Manual 8.1 - Ignition Documentation):

system.net.sendEmail(smtp, fromAddr, [ subject ] , [ body ] , [ html ] , to, [ attachmentNames l] , [ attachmentData l] , [ timeout ] , [ username ] , [ password ] , [priority] , [smtpProfile], [ cc ] , [ bcc ] , [ retries], [replyTo] )

Or is it the html boolean ? Here's what the docs have to say about it:

Boolean html - A flag indicating whether or not to send the email as an HTML email. Will auto-detect if omitted. [optional]

My mail bodies are html indeed, but it appears this flag should be optional.
The emails are sent and received. BUT, the script in charge of sending those emails does exit when the exception is raised, after sending the email. I don't want to try/catch this, I want to fix it, but it's... kind of weird.

Now, even weirder: I have a test mode that I use to... well, test things.
The function in charge of sending the emails has a signature that looks like this:

def send_emails(site, customer=None, test=False)

And I compute the addresses depending on the test mode:

customer_addresses = get_addresses(customer, rosters[customer]) if not test and customer is not None else get_addresses('Test', rosters['Test'])

That's the only part that depends on the test parameter. The mail body is the same, the system.net.sendEmail call is the same, etc.
BUT, I don't get any warning in the logs when I pass test=True to the function.

What the hell is going on ?

edit:
Actually, the mail might not be sent properly. I have 2 calls to system.net.sendEmail (that are very similar), it might be the second one that raises the exception, so the first one does send the email and the second one errors out. But test=True does send BOTH mails without any warning.

Here's what the first one looks like:

if ourcompany_message is not None:
	system.net.sendEmail(
		smtp = "localhost:25",
		fromAddr = "no-reply@mail.com",
		subject = "mail_subject",
		to = ourcompany_addresses,
		body = ourcompany_message
	)

As you can see, the call is basically identical, the difference is in the message body: The first one has some more rows in a table, the rest of it is exactly the same.

Okay folks forget about this, here’s what’s up:
There are no contact info configured for the customer’s roster. No addresses = no emails.

The most obvious issue is sometimes the last one you think of.

3 Likes