| /** | |
| * Create a new transaction object with a unique uuid from a given | |
| * raw email string. This always parses the body. | |
| * | |
| * 'mail_from' and 'rcpt_to' are filled in from the email headers. | |
| * | |
| * @param {string} email the raw full email, including headers | |
| * @return {Transaction} the new unique transaction | |
| */ | |
| function new_transaction(email) { | |
| var email_lines = email.split("\n"); | |
| // create new empty transaction | |
| var t = new Transaction(); | |
| t.uuid = uuid(); | |
| t.parse_body = true; | |
| t.message_stream = new MessageStream( | |
| config.get('smtp.ini'), t.uuid, | |
| t.header.header_list); | |
| // parse the email and fill the object | |
| var i; | |
| for (i = 0; i < email_lines.length; i++) { | |
| t.add_data(email_lines[i]); | |
| } | |
| t.end_data(function() { return ; }) | |
| var from_addr = t.header.get("From").match(/[^@<\s]+@[^@\s>]+/g)[0]; | |
| var to_addr = t.header.get("To").match(/[^@<\s]+@[^@\s>]+/g)[0]; | |
| t.mail_from = new Address(from_addr); | |
| t.rcpt_to = [new Address(to_addr)]; | |
| return t; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment