I've a NestJS application deployed to Firebase wired up with Firebase functions. I've an API which accepts a form data from a different Firebase Angular frontend project (I prefer the BE and FE projects to be separated).
I'd like to send that contact form data through my NestJS backend due to validation purposes via email to the Firebase admin email address (my Google account email) with all the form data, after the validation is succeeded.
So it's basiacally a contact form, by the user, to the admin. I've digged through the documentation and I've found solutions only for the other direction, so the app sends email to the users after something triggers this function (with Nodemailer, and with a 3rd party SMTP mail service).
Is there a solution to send the contact form data to my Gmail (associated with the Firebase account too) in the desired way? Do I really need to use Nodemailer and a 3rd party service to send an email to myself with the data from the contact form?
The process flow should be the following:
Users fills out the contact form
After FE validation the data is sent to the NestJS API
After BE validation the data is sent to my Gmail email address
Thanks for the suggestions in advance!
elyndel
Using Nodemailer would be the easiest option to send an email. You can use the same recipient email as the sender so you don't need any other mail service like SendGrid. Just specify the same email in both from and to:
const mailOptions = {
from: "user#gmail.com",
to: "user#gmail.com",
subject: "New registration",
text: "<Details>",
};
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
} else {
console.log("Email sent: " + info.response);
}
});
I have a Google Group setup called tes#domain.com on my G-mail Account.
In that group, I have 8 members email addresses.
If I send mail to that group from "send-grid", the mail is not been received.
$url = 'https://api.sendgrid.com/';
On Send-grid when I check status of this group-email(tes#domain.com) its show its been "Delivered" and "Opened" as well.
And I also get this SendGrid {"message":"success"} json response
Your group email alias is probably not enabled to receive emails from external sources. You need to update your settings to allow posts from 'anyone'
I am trying to send email to my other email from amazon SES verified email, but the programs gives an error that email address in to field is not verified. I am making a web app which allows user to log in using AWS Cognito so I dont have their email addresses in database. I need to send email to them on an event(I cannot use SNS because I need to send emails to selective persons which I have figured out.) So my questions are:
a)Do we need to verify SES email of the recipient also?
b)If yes, how can we use the cognito identity pool to verify their email addresses for SES.
code:
var aws = require("aws-sdk");
aws.config.update({
region: "us-west-2",
});
var ses = new aws.SES({"accessKeyId": "Mykey", "secretAccessKey":"YY","region":"us-west-2"})
var to = ['xyz#gmail.com']
var from='abc#gmail.com'
ses.sendEmail( {
Source: from,
Destination: { ToAddresses: to },
Message: {
Subject:{
Data:"Sending emails through SES"
},
Body: {
Text: {
Data: 'Stop your messing around',
}
}
}
}
, function(err, data) {
if(err) throw err
console.log('Email sent:');
console.log(data);
}
Error:
MessageRejected: Email address is not verified. The following identities failed the check in region US-WEST-2: xyz#gmail.com
If you're testing this inside your SES sandbox, you need to manually verify the recipient email addresses before it will allow you to send.
This step isn't required after leaving the sandbox, but it's a reasonable default safety setting when testing email-related functionality during development and not wanting bogus emails to go our for real.
Amazon SES Email Sending Errors (relevant portion in bold):
Email address is not verified. The following identities failed the
check in region : , , —You
are trying to send email from an email address or domain that you have
not verified with Amazon SES. This error could apply to the "From",
"Source", "Sender", or "Return-Path" address. If your account is still
in the sandbox, you also must verify every recipient email address
An easier way to test your email sending in AWS without needing to send actual emails would be to use their mailbox simulator:
The Amazon SES mailbox simulator is a set of test email addresses.
Each email address represents a specific scenario. You can send emails
to the mailbox simulator when you want to:
Test your application without having to create test "To" addresses.
Mailgun recommends creating DNS (TXT, MX,..) records for a subdomain, but states sending and receiving with the root domain is possible by later configuration. I created all necessary steps for mail.example.com at my registrar and at Mailgun (adding a domain, setting up routes, etc.).
I can now receive and send emails to the configured example#mail.example.com.
What do I have to change now to be able to send and receive at example#example.com?
What are the necessary changes at the registrar, in mailgun, and in my smtp settings at gmail (for sending from gmail via mailgun)?
Thank you very much!
If you configure Mailgun for a subdomain, you can send emails from your main domain passing a proper to variable. For instance, using Node.js + nodemailer + nodemailer-mailgun-transport:
var nodemailer = require('nodemailer'),
mg = require('nodemailer-mailgun-transport'),
auth = { api_key: 'foobar', domain: 'mail.example.com' },
nodemailerMailgun = nodemailer.createTransport(mg({ auth: auth }));
nodemailerMailgun.sendMail({
from: 'helloworld#example.com',
to: 'recipient#domain.com',
subject: 'Hey you, awesome!',
text: 'Mailgun rocks, pow pow!'
}, someCallback);
Or you can read about other methods of sending through an API in their docs. Anyway, even if your Mailgun is configured for a subdomain, you can send email from your main domain.
However (!) your MX records are configured for your subdomain, and hence you can only receive emails there. To be able to receive email to your main domain, add your main domain in Mailgun's control panel, e.g. not mail.example.com, but example.com, and make an according configuration in your DNS control panel for this main domain, example configuration for DigitalOcean's DNS for example.com (not subdomain):
TXT # v=spf1 include:mailgun.org ~all
TXT krs._domainkey k=rsa; p=MIGfM...blablabla
CNAME email mailgun.org.
MX 10 mxa.mailgun.org.
MX 10 mxb.mailgun.org.
Keep in mind, that Mailgun does not have mailbox functionality, it can only forward incoming emails, if you have an appropriate rule set. Most people delegate their main domain's MX records to a more manageable ESP, like Gmail. You can only have one set of MX records for a domain, so you have to choose, either Gmail, or Mailgun.
You need to use mailgun-js for this
Require mailgun-js from npm
var Mailgun = require('mailgun-js');
2.Set options for mailgun. i.e. apiKey and domain.
var options = {
apiKey: 'YOUR_API_KEY',
domain: 'YOUR_DOMAIN'
};
Instantiate mailgun with these options.
var mailgun = new Mailgun(options);
Send email after setting required parameter for it.
var data = {
//From email
from: '',
// Email to contact
to: 'To Email address',
// CC email
ccTo: 'CC address if any'
// Subject
subject: 'Mail subject',
// Email msg
html: 'email message or html'
};
// Send email
mailGun.messages().send(data, callbackFunction() {
});
I've only been using Mailgun a short time, but I can help with what I've learned so far.
Your DNS records can be setup for Mailgun or a third party like Gmail. I don't think they will use both. I'm not sure what that would do to the routing, because it would not know where to go.
For your Mailgun subdomain, you used mail.example.com with email address example1#mail.example.com. Mine is running, but I did not create email addresses like that at all. My email formats are still example1#example.com.
I am going to paste this in from an email I received, and edit it to match your provided example:
It looks like you have set the MX records for the root domain, example.com, however the domain you are using with Mailgun is mail.example.com. You will need to change the hostname from example.com to mail.example.com for these to route correctly.
As Mailgun does not have mailboxes, receiving email with Mailgun requires using a subdomain with MX records pointing to Mailgun as well as using our Routes functionality. A good way to understand Routes is as a sophisticated filtering and forwarding mechanism. With Routes, you can either:
forward the incoming email to another environment for storage (such as an email address or an endpoint on your server
store a message temporarily (for up to 3 days) and retrieve it using the Messages API
stop a message from being processed (i.e. dropping certain messages instead of forwarding or storing them)
If you're trying to use Django's Anymail package to send Mailgun email from a subdomain, you need to send the email using the EmailMultiAlternatives object and specify the Email Sender Domain like so:
from django.core.mail import EmailMultiAlternatives
msg = EmailMultiAlternatives("Subject", "text body",
"contact#example.com", ["to#somedomain.com"])
msg.esp_extra = {"sender_domain": "mg.example.com"}
msg.send()
I would like to preserve the Email Subject & email Message that are defined on the Docusign Template and send those vs sending generic email subject & message when sending a document via Custom Button in Salesforce? Below is my button code
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
var DST='<Docusign Template Id>';
var LA='0';
var OSO = 'Send';
var CRL = 'Email~{!Fulfillment__c.Primary_Contact_Email__c};Role~Client;FirstName~ {!Fulfillment__c.Primary_Contact_First_Name__c};LastName~{!Fulfillment__c.Primary_Contact_Last_Name__c}';
var CCRM='Client~Client';
window.location.href = '/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID='+eSignatureNotSent.Id+'&DST='+DST+'&LA='+LA+'&CRL='+CRL+'&OCO='+OCO+'&CCRM='+CCRM;
I think Docusign is using Default Email Subject and Default Email Message defined in the Admin settings in Salesforce. I do not want to send it as all the work is done when building templates in Docusign.
If you leave the Default Email Message blank in the Admin settings, it will grab the contents of the Template Email Message.
The API has a hard requirement to define an email subject through the request. Currently because Salesforce uses the API, it has to follow this guideline.
My best advice is making a custom button that defines the Email subject that you'd like for each workflow that you may have.