Skip to content

clients.mailclient #

mailclient

To get started


import freeflowuniverse.crystallib.clients. mailclient

mut client:= mailclient.get()!

client.send(subject:'this is a test',to:'kds@something.com,kds2@else.com',body:'
    this is my email content
    ')!

example heroscript

!!mailclient.configure
    secret: '...'
    host: 'localhost'
    port: 8888

use of env variables

if you have a secrets file you could import as

//e.g.  source ~/code/git.ourworld.tf/despiegk/hero_secrets/mysecrets.sh

following env variables are supported

  • MAIL_FROM=
  • MAIL_PASSWORD=
  • MAIL_PORT=465
  • MAIL_SERVER=smtp-relay.brevo.com
  • MAIL_USERNAME=kristof@incubaid.com

these variables will only be set at configure time

brevo remark

  • use ssl
  • use port: 465

Constants #

const version = '1.0.0'

fn configure #

fn configure(config MailClient) !MailClient

user needs to us switch to make sure we get the right object

fn get #

fn get(args_ ArgsGet) !&MailClient

fn heroscript_default #

fn heroscript_default() string

Todo: THIS IS EXAMPLE CODE AND NEEDS TO BE CHANGED IN LINE TO STRUCT BELOW, IS STRUCTURED AS HEROSCRIPT

fn play #

fn play(args_ InstallPlayArgs) !

fn switch #

fn switch(name string)

switch instance to be used for mailclient

enum BodyType #

enum BodyType {
	text
	html
	markdown
}

struct ArgsGet #

@[params]
struct ArgsGet {
pub mut:
	name string = 'default'
}

///////FACTORY

struct InstallPlayArgs #

@[params]
struct InstallPlayArgs {
pub mut:
	name       string = 'default'
	heroscript string // if filled in then plbook will be made out of it
	plbook     ?playbook.PlayBook
	reset      bool
	start      bool
	stop       bool
	restart    bool
	delete     bool
	configure  bool // make sure there is at least one installed
}

struct MailClient #

struct MailClient {
pub mut:
	name          string = 'default'
	mail_from     string
	mail_password string @[secret]
	mail_port     int = 465
	mail_server   string
	mail_username string
	ssl           bool = true
	tls           bool
}

fn (MailClient) send #

fn (mut cl MailClient) send(args_ SendArgs) !
cl.send(markdown:true,subject:'this is a test',to:'kds@something.com,kds2@else.com',body:'
    this is my email content
    ')!
args:
    markdown  bool
    from      string
    to        string
    cc        string
    bcc       string
    date      time.Time = time.now()
    subject   string
    body_type BodyType (.html, .text, .markdown)
    body      string

struct SendArgs #

@[params]
struct SendArgs {
pub mut:
	markdown  bool
	from      string
	to        string
	cc        string
	bcc       string
	date      time.Time = time.now()
	subject   string
	body_type BodyType
	body      string
}