forked from frappe/books
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
3,220 additions
and
1,604 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const frappe = require('frappejs'); | ||
module.exports = async function getData() { | ||
account = await frappe.getDoc('EmailAccount'); | ||
return account; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const nodemailer = require('nodemailer'); | ||
const getConfig = require("./getConfig"); | ||
const validator = require('./validator'); | ||
|
||
module.exports = { | ||
'sendMail': async function (mailDetails) { | ||
if (!validator.validate(mailDetails.fromEmailAddress)) { | ||
console.log("INVALID EMAIL"); | ||
return false; | ||
} | ||
|
||
let account = await getConfig(); | ||
if (mailDetails.fromEmailAddress == account.email) { | ||
if (validator.validate(mailDetails.toEmailAddress)) { | ||
mailDetails = { | ||
from: mailDetails.fromEmailAddress, | ||
to: mailDetails.toEmailAddress, | ||
replyTo: mailDetails.toEmailAddress, | ||
inReplyTo: mailDetails.replyId, | ||
references: [mailDetails.replyId], | ||
cc: mailDetails.ccEmailAddress, | ||
bcc: mailDetails.bccEmailAddress, | ||
subject: mailDetails.subject, | ||
text: mailDetails.bodyText, | ||
attachments: [{ | ||
filename: 'Invoice.pdf', | ||
path: mailDetails.filePath, | ||
contentType: 'application/pdf' | ||
}], | ||
}; | ||
let transporter = nodemailer.createTransport({ | ||
service: 'gmail', | ||
auth: { | ||
user: account.email, | ||
pass: account.password, | ||
} | ||
}); | ||
transporter.sendMail(mailDetails); | ||
return true; | ||
} else { | ||
console.log("Sender Email Invalid"); | ||
return false; | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// + Check Confirm Password == Password | ||
|
||
module.exports = { | ||
validate: function (email) { | ||
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; | ||
if (reg.test(email) == false) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.