flashmob / go-guerrilla

Mini SMTP server written in golang
MIT License
2.79k stars 366 forks source link

MySQL table creation #79

Closed clanstyles closed 6 years ago

clanstyles commented 7 years ago

I tried to create my own table and I'm missing some data. Where is the table schema that was used with this?

flashmob commented 7 years ago

For the MySql processor (not the redis-mysqll one) please try the following


create table new
(
    mail_id bigint not null auto_increment,
    message_id varchar(256) not null,
    date datetime not null,
    `from` varchar(256) not null,
    `to` varchar(256) not null,
    reply_to varchar(256) null,
    sender varchar(256) null,
    subject varchar(255) not null,
    body varchar(16) not null,
    mail longblob not null,
    spam_score float not null,
    hash char(32) not null,
    content_type varchar(64) not null,
    recipient varchar(255) not null,
    has_attach int not null,
    ip_addr varbinary(16) not null,
    return_path varchar(255) not null,
    is_tls bit default b'0' not null,
    constraint `PRIMARY`
        primary key (mail_id)
)
;

create index date
    on new (date)
;

create index hash
    on new (hash)
;

create index `to`
    on new (`to`)
;

comment on column new.message_id is 'value of [Message-ID] from headers'
;

comment on column new.`from` is 'value of [From] from headers or return_path (MAIL FROM) if no header present'
;

comment on column new.`to` is 'value of [To] from headers or recipient (RCPT TO) if no header present'
;

comment on column new.reply_to is 'value of [Reply-To] from headers if present'
;

comment on column new.sender is 'value of [Sender] from headers of present'
;

comment on column new.recipient is 'set by the RCPT TO command.'
;

comment on column new.return_path is 'set by the MAIL FROM command. Can be empty to indicate a bounce, i.e <>'
;
clanstyles commented 7 years ago

Thanks. Is there anyway to get the body of the message 

Sent via the Samsung Galaxy S®6 active, an AT&T 4G LTE smartphone -------- Original message --------From: Flashmob notifications@github.com Date: 4/6/17 4:29 PM (GMT-06:00) To: flashmob/go-guerrilla go-guerrilla@noreply.github.com Cc: clanstyles counterstrike.styles@gmail.com, Author author@noreply.github.com Subject: Re: [flashmob/go-guerrilla] MySQL table creation (#79) For the MySql processor (not the redis-mysqll one) please try the following create table new ( mail_id bigint not null auto_increment, message_id varchar(256) not null, date datetime not null, from varchar(256) not null, to varchar(256) not null, reply_to varchar(256) null, sender varchar(256) null, subject varchar(255) not null, body varchar(16) not null, mail longblob not null, spam_score float not null, hash char(32) not null, content_type varchar(64) not null, recipient varchar(255) not null, has_attach int not null, ip_addr varbinary(16) not null, return_path varchar(255) not null, is_tls bit default b'0' not null, constraint PRIMARY primary key (mail_id) ) ;

create index date on new (date) ;

create index hash on new (hash) ;

create index to on new (to) ;

comment on column new.message_id is 'value of [Message-ID] from headers' ;

comment on column new.from is 'value of [From] from headers or return_path (MAIL FROM) if no header present' ;

comment on column new.to is 'value of [To] from headers or recipient (RCPT TO) if no header present' ;

comment on column new.reply_to is 'value of [Reply-To] from headers if present' ;

comment on column new.sender is 'value of [Sender] from headers of present' ;

comment on column new.recipient is 'set by the RCPT TO command.' ;

comment on column new.return_path is 'set by the MAIL FROM command. Can be empty to indicate a bounce, i.e <>' ;

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/flashmob/go-guerrilla","title":"flashmob/go-guerrilla","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/flashmob/go-guerrilla"}},"updates":{"snippets":[{"icon":"PERSON","message":"@flashmob in #79: For the MySql processor (not the redis-mysqll one) please try the following\r\n\r\n\r\nsql\r\n\r\ncreate table new\r\n(\r\n\tmail_id bigint not null auto_increment,\r\n\tmessage_id varchar(256) not null,\r\n\tdate datetime not null,\r\n\t`from` varchar(256) not null,\r\n\t`to` varchar(256) not null,\r\n\treply_to varchar(256) null,\r\n\tsender varchar(256) null,\r\n\tsubject varchar(255) not null,\r\n\tbody varchar(16) not null,\r\n\tmail longblob not null,\r\n\tspam_score float not null,\r\n\thash char(32) not null,\r\n\tcontent_type varchar(64) not null,\r\n\trecipient varchar(255) not null,\r\n\thas_attach int not null,\r\n\tip_addr varbinary(16) not null,\r\n\treturn_path varchar(255) not null,\r\n\tis_tls bit default b'0' not null,\r\n\tconstraint `PRIMARY`\r\n\t\tprimary key (mail_id)\r\n)\r\n;\r\n\r\ncreate index date\r\n\ton new (date)\r\n;\r\n\r\ncreate index hash\r\n\ton new (hash)\r\n;\r\n\r\ncreate index `to`\r\n\ton new (`to`)\r\n;\r\n\r\ncomment on column new.message_id is 'value of [Message-ID] from headers'\r\n;\r\n\r\ncomment on column new.`from` is 'value of [From] from headers or return_path (MAIL FROM) if no header present'\r\n;\r\n\r\ncomment on column new.`to` is 'value of [To] from headers or recipient (RCPT TO) if no header present'\r\n;\r\n\r\ncomment on column new.reply_to is 'value of [Reply-To] from headers if present'\r\n;\r\n\r\ncomment on column new.sender is 'value of [Sender] from headers of present'\r\n;\r\n\r\ncomment on column new.recipient is 'set by the RCPT TO command.'\r\n;\r\n\r\ncomment on column new.return_path is 'set by the MAIL FROM command. Can be empty to indicate a bounce, i.e \u003c\u003e'\r\n;\r\n\r\n\r\n\r\n"}],"action":{"name":"View Issue","url":"https://github.com/flashmob/go-guerrilla/issues/79#issuecomment-292329239"}}}

flashmob commented 7 years ago

The content of the email would be saved in mail

You may also be interested wiki page for how to configure with redis + mysql https://github.com/flashmob/go-guerrilla/wiki/Configuration-example:-save-to-Redis-&-MySQL