Skip to content

Commit

Permalink
feat:automated thankyou email
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayesha-Siddiqua88 committed Jun 3, 2024
1 parent e5372a4 commit d27c2fb
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 60 deletions.
16 changes: 10 additions & 6 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,16 @@ textarea.input-field {
gap: 10px;
}

.subscribe-btn{
background-color: var(--old-rose);
color: var(--white);
height: 4rem;
padding: 2px 20px;
border-radius: 5px;
cursor: pointer;

}

.social-link {
background-color: var(--old-rose);
color: var(--white);
Expand Down Expand Up @@ -1462,12 +1472,9 @@ textarea.input-field {

}

<<<<<<< Updated upstream
=======
.circle-container {
display: none;
}
>>>>>>> Stashed changes
}

@media only screen and (max-width: 600px) {
Expand Down Expand Up @@ -3155,7 +3162,6 @@ body.dark-mode .h3 {
.preference-bar select {
font-size: 20px;
}
<<<<<<< Updated upstream
}

/* media queries for chat widget */
Expand All @@ -3177,6 +3183,4 @@ body.dark-mode .h3 {
.bp-widget-web.bp-widget-web{
right: calc(4.95% - 23px) ;
}
=======
>>>>>>> Stashed changes
}
5 changes: 2 additions & 3 deletions assets/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1407,9 +1407,8 @@ <h2>Quick Links</h2>



<!--email write-->
<input type="news" value="" name="email" placeholder="email address" required>
<input type="submit" value="Subscribe" name="subscribe" class="subscribe-btn" >
<input type="news" value="" name="email" placeholder="email address" id="newsletter-email">
<button type="submit" class="subscribe-btn">subscribe</button>
</div>
</form>
<div class="icons">
Expand Down
37 changes: 37 additions & 0 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
'use strict';
const nodemailer=require('nodemailer');
require('dotenv').config();

const transporter=nodemailer.createTransport({
service:'gmail',
host:'smtp.gmail.com',
port:587,
secure:false,
auth:{
user:"[email protected]",
pass:process.env.APP_PASSWORD
}
})

const mailOptions={
from:{
name:'SwapReads',
address:"[email protected]"
},
to:"[email protected]",
subject:'Welcome to Our Newsletter!',
text:"Hello, Thank you for subscribing to our newsletter! Stay tuned for exciting updates.",
}


const sendMail=async(transporter,mailOptions)=>{
try{
await transporter.sendMail(mailOptions);
console.log('Email sent successfully');
}
catch(error){
console.error('Error sending email:',error);
}
}

const subscribeBtn=document.querySelector('.subscribe-btn');
subscribeBtn.addEventListener('click',sendMail(transporter,mailOptions));

// add event on send message button
const sendMessageBtn = document.getElementById('sendMessageBtn');
Expand Down
22 changes: 18 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1596,9 +1596,8 @@ <h2>Quick Links</h2>



<!--email write-->
<input type="news" value="" name="email" placeholder="email address" required>
<input type="submit" value="Subscribe" name="subscribe" class="subscribe-btn">
<input type="news" value="" name="email" placeholder="email address" id="newsletter-email">
<button type="submit" class="subscribe-btn">subscribe</button>
</div>
</form>
<style>
Expand Down Expand Up @@ -1679,9 +1678,25 @@ <h2>Quick Links</h2>

</footer>
<!-- Footer ended-->
<script src="./assets/js/script.js" defer></script>

<script>

// function sendMail(){
// let params={
// name:document.getElementById('name').value,
// email:document.getElementById('email').value,
// subject:document.getElementById('subject').value,
// message:document.getElementById('message').value,
// subscribe:document.getElementById('newsletter-email').value
// }
// EmailJSResponseStatus.send("service_lktb68z","template_w79vd94",params,"o6kveYmOSDrs0l1Mg")
// .then(alert('Email sent successfully'))
// }


// document.querySelector('subscribe-btn').addEventListener('submit', sendMail());

//Custom Cursor

const coords = { x: 0, y: 0 };
Expand Down Expand Up @@ -1818,7 +1833,6 @@ <h2>Quick Links</h2>
<!--
- custom js link
-->
<script src="./assets/js/script.js" defer></script>

<!--
- ionicon link
Expand Down
43 changes: 42 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"express": "^4.19.2"
},
"dependencies": {
"@emailjs/browser": "^4.3.3",
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"mongoose": "^8.3.5",
"nodemailer": "^6.9.13",
"nodemon": "^3.1.1",
Expand Down
47 changes: 1 addition & 46 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,49 +90,4 @@ dbConnect().then(() => {
res.json({ success: false, message: "Internal Server Error" });
});
});

// Configure Nodemailer transporter
const transporter = nodemailer.createTransport({
service: "gmail",
auth: {
user: "[email protected]",
pass: "password",
},
});

function sendBuyingEmailToSeller(sellerEmail, bookTitle, bookPrice, bookAuthor, buyerEmail) {
const mailOptions = {
from: "[email protected]",
to: sellerEmail,
subject: "Someone is interested in your book!",
text: `Congratulations! Your book "${bookTitle}" by ${bookAuthor} at ${bookPrice} has a Buyer ${buyerEmail}.`,
};

transporter.sendMail(mailOptions, (err, info) => {
if (err) {
console.error("Error sending email:", err);
} else {
console.log("Email sent:", info.response);
}
});
}

function sendListingEmailToSeller(sellerEmail, bookTitle) {
const mailOptions = {
from: "[email protected]",
to: sellerEmail,
subject: "Your book listing is live!",
text: `Congratulations! Your book "${bookTitle}" is now listed for sale.`,
};

transporter.sendMail(mailOptions, (err, info) => {
if (err) {
console.error("Error sending email:", err);
} else {
console.log("Email sent:", info.response);
}
});
}

app.listen(3000, () => console.log("Server is running on port 3000"));
});
});

0 comments on commit d27c2fb

Please sign in to comment.