Skip to content

Email

Send email messages using the Mailgun messaging service.

Mailgun Account Required

A valid Mailgun account and the proper configuration must be set up to use the email module. See the Configuration section below. The Mailgun messaging service allows you to send up to 10,000 free email messages a month.

Screencast Available

Learn about sending email in a screencast format by Clicking here.

new

Create a new email message object.

core.email.new([key][, domain])

Parameters

Name Description Type Required
key Your Mailgun API key. String N
domain Your verified Mailgun domain. String N

Default Credentials

If you have already set your Mailgun credentials using the Webmin then these will be used by default, and you do not need to include the key and domain arguments.

Returns

A new email message object based on the Mailgun credentials.

Example

local msg = core.email.new()

Message Object

to

The address(es) to send the message to. Multiple values must be seperated by a comma. This is a required value.

msg:to( address[, addressN] )

Parameters

Name Description Type
address The recipient address(es). String

Examples

Single address:

--Address only
msg:to("user@email.com")

--With name
msg:to("Chris <user@email.com>")

Multiple addresses:

msg:to("user1@email.com", "Jim <user2@email.com>")

from

The message sender address. This is a required value.

msg:from( address )

Parameters

Name Description Type
address The sender address. String

Example

msg:from("sender@email.com")

cc

The address(es) to "cc" the message to. Multiple values must be seperated by a comma.

msg:cc( address[, addressN] )

Parameters

Name Description Type
address The "cc" address(es). String

Examples

Single address:

--Address only
msg:cc("user@email.com")

--With name
msg:cc("Chris <user@email.com>")

Multiple addresses:

msg:cc("user1@email.com", "Jim <user2@email.com>")

bcc

The address(es) to "bcc" the message to. Multiple values must be seperated by a comma.

msg:bcc( address[, addressN] )

Parameters

Name Description Type
address The "bcc" address(es). String

Examples

Single address:

--Address only
msg:bcc("user@email.com")

--With name
msg:bcc("Chris <user@email.com>")

Multiple addresses:

msg:bcc("user1@email.com", "Jim <user2@email.com>")

replyTo

Sets a specific reply-to address. If not set, the sender address is the default.

msg:replyTo( address )

Parameters

Name Description Type
address A specific reply-to address. String

Example

msg:replyTo("Support <support@email.com>")

subject

The subject line for the email. The default is "(no subject)" if not provided.

msg:subject( subject_str )

Parameters

Name Description Type
subject_str The subject title. String

Example

msg:subject("A Super Email")

text

The plain text version of the message body.

msg:text( message_str )

Parameters

Name Description Type
message_str A plain string message. String

Example

msg:text("Here is your plain information.")

html

The html version of the message body.

msg:html( message_html )

Parameters

Name Description Type
message_html An html string message. String

Example

msg:html("Here is your <b>bold</b> information.")

tag

Sets a specific tag for the email. Can be used for tracking in Mailgun.

msg:tag( tag_str )

Parameters

Name Description Type
tag_str A string tag for tracking. String

Example

msg:tag("appuser")

requireTls

Force Mailgun to use TLS when sending the message. Defaults to false.

msg:requireTls( bool )

Parameters

Name Description Type
bool Whether to enable TLS for this message. Boolean

Example

msg:requireTls(true)

skipVerification

Skip certificate verification when using TLS. Defaults to false.

msg:skipVerification( bool )

Parameters

Name Description Type
bool Whether to skip verification in TLS. Boolean

Example

msg:skipVerification(true)

testMode

Used for debugging in Mailgun. Defaults to false.

msg:testMode( bool )

Parameters

Name Description Type
bool Whether to enable test mode. Boolean

Example

msg:testMode(true)

send

Send the final message via Mailgun.

msg:send()

Parameters

This method takes no parameters.

Example

local resp, err = msg:send()

Configuration

To use the Email module you will need a valid Mailgun account.

Once you have your account set-up you will need to provide your Sending Domain and Secret API Key from Mailgun to your Coronium Core system.

Using the Webmin, navigate to the Config section and enter the requested information in the Mailgun Settings area. Click the update button to add your credentials.

You can now use the Email module for sending email.