Is there any contact us email integration?
I want to know if there is email integration, where user could send emails to the user over the website interface
15 Replies
Hi @skyblade2954. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, Wasp does provide email integration. You can easily integrate email functionality into your web application using Wasp's email-sending feature. You can choose from one of the providers such as
Dummy
(for development only), Mailgun
, SendGrid
, or the good old SMTP
.
Here is an example of how you can set up the email sender in your main.wasp
file:
You can also define the defaultFrom
field, so you don't need to provide it whenever sending an email.
To send emails, you import the emailSender
that is provided by the wasp/server/email
module and call the send
method on it. Here is an example:
The send
method returns an object with the status of the sent email. It varies depending on the provider you use.
For more details, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/advanced/email).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @skyblade2954, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai @Wasp Team Do you guys simple GUI interface tutorial for "Contact Us" page? With html and css?
Let me check the knowledge base for you. One moment! :books:
----------------------
I'm sorry, but the provided knowledge sources do not contain a specific tutorial for creating a "Contact Us" page with a GUI interface using HTML and CSS in the Wasp framework. However, Wasp does provide a way to create pages using React components and you can style them using CSS or CSS frameworks like Tailwind CSS.
Here is a basic example of how you can create a page in Wasp:
You can then style this page using CSS or a CSS framework of your choice.
For more detailed information on how to create and style pages in Wasp, you can refer to the Wasp documentation (https://wasp-lang.dev/docs).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @skyblade2954, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
Nope we don't offer a GUI for that, but as Kapa said, we do offer email sending, so if you create your own form and have it trigger a Wasp Action that sends email via email sender, that is it!
@martinsos Yes, thank you I can do that, however you can also add it to your tutorial section. You made a GUI implementation for email authentication, you can also add this one too. Not a big deal.
@martinsos It would be really easy for some people who don't know too much about react, would get a example page, it would improve their speed.
Open SaaS
Free, open-source SaaS boilerplate starter for React & NodeJS.
@matija I used this https://www.geeksforgeeks.org/create-a-contact-form-using-html-css-javascript/ and wrote one simple react html code. I removed several sections but it was usefull with simple validate function. Removed background etc. Let me share the file.
GeeksforGeeks
Create a Contact Form using HTML CSS & JavaScript - GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Wohooo @skyblade2954, you just became a Waspeteer level 2!
@matija
You can remove the header and footer, it might be usefull for the Wasp tutorial section.
How did u send mails withbthis form
From what email to which?
Because now i send mails from myself to myself
I can send from mail [email protected] to any mail address
that mail address I got from probably mail service provider
SENDGRID
import { emailSender } from 'wasp/server/email';
import SendGrid from '@sendgrid/mail';
SendGrid.setApiKey(process.env.SENDGRID_API_KEY);
export const sendGUIMailRequest = async (args, context) => {
try {
const { inputName, inputEmail, inputSubject, inputPhone, inputEmailBody, uploadedFile, } = args;
// Server-side validation
if (!uploadedFile.type.startsWith('image/')) {
throw new Error('Invalid file type. Only images are allowed.');
}
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
if (Buffer.byteLength(uploadedFile.data, 'base64') > MAX_FILE_SIZE) {
throw new Error('File size exceeds the maximum limit of 5MB.');
}
const emailText =
Name: ${inputName}
Email: ${inputEmail}
Phone: ${inputPhone}
Message: ${inputEmailBody}
;
const emailHtml =
<p><strong>Name:</strong> ${inputName}</p>
<p><strong>Email:</strong> ${inputEmail}</p>
<p><strong>Phone:</strong> ${inputPhone}</p>
<p><strong>Message:</strong></p>
<p>${inputEmailBody}</p>
;
const msg = {
from: {
email: '[email protected]',
name: 'customer',
},
to: '[email protected]',
subject: inputSubject,
text: emailText,
html: emailHtml,
attachments: [
{
content: uploadedFile.data,
filename: uploadedFile.name,
type: uploadedFile.type,
disposition: 'attachment',
},
],
};
await SendGrid.send(msg);
return { success: true };
}
catch (error) {
console.error('Error in sendMailWithAttachment action:', error);
throw error;
}
};
export default sendGUIMailRequest;
//# sourceMappingURL=SendEmail.js.map
My last code is like this
I am sending images tooYeah but like when a user fills in form
You send a mail to urself or right?
From what mail exactly? A different mail adress
I had implemented a similar option without mail integration: https://toograded.com/contact-us
and implemented the
/admin/messages
pageexport const createMessage: CreateMessage = async ({ firstName, lastName, email, message }, context) => {
return context.entities.Message.create({
data: {
firstName,
lastName,
email,
message
}
})
}
export const getMessages: GetMessages = async (args, context) => {
return context.entities.Message.findMany({
orderBy: {
timestamp: 'desc'
}
})
}