The contact section of Hector Portfolio lets visitors send messages directly from the browser using EmailJS. EmailJS acts as a bridge between the client-side form and a real email service (Gmail, Outlook, etc.), meaning there is no Node.js endpoint, no server deployment, and no CORS configuration needed to receive contact messages.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/iwinser117/react-portafolio/llms.txt
Use this file to discover all available pages before exploring further.
How EmailJS Works
When the form is submitted, the@emailjs/browser package makes a direct HTTPS call to EmailJS servers, which in turn forward the message to the configured email service using the credentials you provide. Everything runs in the visitor’s browser.
The Three Identifiers
Everyemailjs.sendForm() call requires three pieces of information. Two are already hard-coded in src/components/Formulario.jsx; one must be supplied via an environment variable.
| Identifier | Source | Value |
|---|---|---|
| Service ID | Environment variable Email_key | Your own EmailJS service ID |
| Template ID | Hard-coded in Formulario.jsx | "template_40uel95" |
| Public Key | Hard-coded in Formulario.jsx | "tvVn2ElRQmSkAAMc2" |
Form Fields
The<form> element uses a React ref (form.current) so that EmailJS can read the field values directly from the DOM. Each field name must match the template variables defined in your EmailJS template.
name attribute | Type | Label key |
|---|---|---|
user_name | text | contact.name |
user_email | email | contact.email |
asunto | text | contact.subject |
message | textarea | contact.message |
Setup Steps
Create an EmailJS account
Go to https://www.emailjs.com and sign up for a free account. The free tier allows up to 200 emails per month.
Create a service and note the Service ID
In the EmailJS dashboard, navigate to Email Services and connect your email provider (Gmail, Outlook, or any SMTP service). After saving, EmailJS generates a Service ID (e.g.
service_xxxxxxx). Copy it — you will need it in step 4.Create an email template with the required variables
Go to Email Templates and create a new template. Your template body must reference these four variables so that the values submitted by the visitor are forwarded correctly:Save the template. The template ID is already set to
template_40uel95 in the source — if you use a different template, update that string in Formulario.jsx.Set the Email_key environment variable
Create a The project uses Webpack with
.env file in the project root (if one does not already exist) and add your Service ID:webpack.DefinePlugin, which statically replaces process.env.Email_key in the bundle at build time using dotenv. Formulario.jsx reads this value on mount.Verify the public key and template ID
The public key (
tvVn2ElRQmSkAAMc2) and the template ID (template_40uel95) are already hard-coded in src/components/Formulario.jsx. If you are using your own EmailJS account you must replace both values with your own account’s public key (found under Account → API Keys) and your template ID.Never commit your The
.env file to version control. Add it to .gitignore immediately:Email_key value grants sending rights on your EmailJS service and should be treated as a secret.Success and Error Callbacks
Afteremailjs.sendForm() resolves, two helper functions from src/utils/sendForm.js display user feedback via SweetAlert2:
exito() — Success notification
Displays a centred SweetAlert2 modal with a success icon. It auto-closes after 2 seconds.
noEnviado() — Error notification
Displays a SweetAlert2 modal with an error icon and a message asking the user to fill in all fields.
Form Toggle UI
The contact section includes a circular toggle button that shows or hides the form. TheviewForm state is initialised to true, meaning the form is open by default when the page loads.
maxHeight.