clients.mailclient #
mailclient
To get started
import freeflowuniverse.herolib.clients.mailclient
//remove the previous one, otherwise the env variables are not read
mailclient.config_delete(name:'test')!
// env variables which need to be set are:
// - MAIL_FROM=...
// - MAIL_PASSWORD=...
// - MAIL_PORT=465
// - MAIL_SERVER=...
// - MAIL_USERNAME=...
mut client:= mailclient.get(name:'test')!
println(client)
client.send(subject:'this is a test',to:'kristof@incubaid.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 = '0.0.0'
fn config_delete #
fn config_delete(args_ ArgsGet) !
fn config_exists #
fn config_exists(args_ ArgsGet) bool
fn config_load #
fn config_load(args_ ArgsGet) !
fn config_save #
fn config_save(args_ ArgsGet) !
fn get #
fn get(args_ ArgsGet) !&MailClient
fn heroscript_default #
fn heroscript_default(args DefaultConfigArgs) !string
fn play #
fn play(args_ PlayArgs) !
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
}
///////FACTORY
struct DefaultConfigArgs #
@[params]
struct DefaultConfigArgs {
instance string = 'default'
}
helpers
struct MailClient #
@[heap]
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 PlayArgs #
@[params]
struct PlayArgs {
pub mut:
heroscript string // if filled in then plbook will be made out of it
plbook ?playbook.PlayBook
reset bool
}
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
}