logo
Tags down

shadow

How to send email with ReactJS and SendGrid?


By : shruti gupta
Date : October 18 2020, 06:10 AM
I wish this help you I have setup and account on SendGrid. I have got the API key and Node.js methods. I am creating an web app with React js. I want to send emails through SendGrid. I am unable to find any solution. Please help me with my question with an example.
code :
//Form.js
class Form extends React.Component {
  constructor() {
    super();
    this.handleSubmit = this.handleSubmit.bind(this);
  }

  handleSubmit(event) {
    event.preventDefault();
    const data = new FormData(event.target);

    fetch('/api/form-submit-url', {
      method: 'POST',
      body: data,
    });
  }

  render() {
    return (
      <form onSubmit={this.handleSubmit}>
        <label htmlFor="username">Enter username</label>
        <input id="username" name="username" type="text" />

        <label htmlFor="email">Enter your email</label>
        <input id="email" name="email" type="email" />

        <label htmlFor="birthdate">Enter your birth date</label>
        <input id="birthdate" name="birthdate" type="text" />

        <button>Send data!</button>
      </form>
    );
  }
}
//index.js

    const sgMail = require('@sendgrid/mail');
    sgMail.setApiKey(process.env.SENDGRID_API_KEY);
    const msg = {
      to: test@example.com',
      from: 'test@example.com',
      subject: 'Sending with SendGrid is Fun',
      text: 'and easy to do anywhere, even with Node.js',
      html: '<strong>and easy to do anywhere, even with Node.js</strong>',
    };

sgMail.send(msg);


Share : facebook icon twitter icon

NoMethodError: undefined method `email' for nil:NilClass : can't send email with devise/sendgrid(Rails 3.2)


By : vishakha
Date : March 29 2020, 07:55 AM
it should still fix some issue That was a bit misleading, though a bit reckless on my end; the error was never from calling email on nil object (as the title stated), and I should've noticed that you're using Devise so all requests are handled by its RegistrationsController. That said, please change the title, and ignore or delete users_controller; it's not the one that's handling the registration requests.
Then add the following lines to your User model:
code :
after_create { Notifier.welcome_email(self).deliver }

Can't send email through SendGrid


By : shivu
Date : March 29 2020, 07:55 AM
it fixes the issue Does this happen to be a console application? I've been testing SendGrid and found that when I try to send an email from a Console application the emails are never sent. However, when I tried it from a web application (using the same exact sending code) the emails are sent. I have no explanation for why the console application does not work.

Using the sendgrid node-module, how do I send a SendGrid Template Engine email?


By : rgbarsotti
Date : March 29 2020, 07:55 AM
around this issue Yep, it's really easy, you just need to add it in as a filter. Here's how it should look:
code :
var cardEmail = new sendgrid.Email({
  to: "theuser@somedomain.com",
  from: "bignews@yourdomain.com",
  subject: process.env.SUBJECT,
  html: '<h2>Thanks for requesting a business card!</h2>', // This fills out the <%body%> tag inside your SendGrid template
});

// Tell SendGrid which template to use, and what to substitute. You can use as many substitutions as you want.
cardEmail.setFilters({"templates": {"settings": {"enabled": 1, "template_id": "325ae5e7-69dd-4b95-b003-b0109f750cfa"}}}); // Just replace this with the ID of the template you want to use
cardEmail.addSubstitution('-greeting-', "Happy Friday!"); // You don't need to have a substitution, but if you want it, here's how you do that :)

// Everything is set up, let's send the email!
sendgrid.send(cardEmail, function(err, json){
  if (err) {
    console.log(err);
  } else {
    console.log('Email sent!');
  }
});

Can Azure Web App receive email SMTP, and send email (SendGrid)?


By : Kiran Raju
Date : March 29 2020, 07:55 AM
With these it helps Outgoing email using SendGrid will not be a problem at all. Using it on App Service is common and you probably don't need to change any code at all.
Inbound may require changes depending on what you're doing. Are you simply polling a mailbox somewhere else and then doing something with the messages? If so, you could convert that to a scheduled WebJob poll at a specific interval and act on incoming messages.

Send Email via sendgrid using v3 API


By : ToQoz
Date : March 29 2020, 07:55 AM
around this issue I am trying to send the emails via Sendgrid using v3 API doing so, I want to pass the json data similar to this , You need to add [] - brackets to your 'to' array. Please have a look.
code :
'to' => [
    [ // add this brackets
        'email' => 'ashuomble5@gmail.com',
        'name' => 'Ashutosh'
    ] // add this brackets 
],
Related Posts Related Posts :
  • Difference between route and endpoint?
  • angular ngIf condition inside ngFor for to display like button
  • Why is module.exports=router is needed?
  • Node.js check if running locally or in google cloud VM?
  • Node TypeScript delete require cache
  • Error: ENOENT: no such file or directory, open 'F:\login\uploads\2019-05-12T18:23:38.048Z20190319_214122.jpg'
  • 'nvm' is not recognized as an internal or external command Windows
  • aws-xray captureAWS annotations
  • In Angular, what are the advantages of using Renderer over ElementRef?
  • How to get an "Image in cell" URL from the Google Sheets API
  • Missing Script when I run npm start to create React app
  • node install some times have @ and not always
  • npm WARN tar ENOENT no such file or directory node_modules/.staging/typescript-8be04997/lib/zh-CN/diagnosticMessages.gen
  • Loop through set of results in node js
  • Why deployed serverless functions not displayed in list of lambda functions in AWS console?
  • Where should I define the DocumentClient when using ExpressJs?
  • Node.js and mongoDB multiple concurrent request for shopping cart checkout function
  • How to fix ' Support for the experimental syntax 'exportDefaultFrom' isn't currently enabled' in node
  • how do i declare a custom function in twilio function runtime environment?
  • Slow loading web page served by Node.js HTTP server
  • How to get Session Entities to work as part of Dialogflow detect intent
  • Namecheap: Node JS Express App - App Route return 404 not found
  • How to create m3u8 playlist from mp4 video url ( stored in amazon S3 ) and store the video chunks ( .ts files) and .m3u8
  • How to write aeropike service file so that it reconnects if connection failed?
  • How to mock API client created inside a test class?
  • Failed at the node-expat@2.3.17 install script - Happens with any NPM installation
  • Node module path alias with experimental modules
  • How to get the Base Url in Twig
  • Actions-On-Google Card Subtitle not displaying in Simulator or Android phone
  • Creating Node.js enum in code to match list of values in database
  • How do I install fonts in the IBM Cloud nodejs runtime? (cloud foundry)
  • Can we read files from server path using any fs method in NodeJs
  • NodeJS, DiscordJS command arguments split by {}
  • Values are set as null inside the database when the respective values are not passed while updating
  • The "path" argument must be of type string. Received type object - Angular 7
  • Find out all running node.js application with pid and port
  • Deploying React express App on Google app engine: 404 error
  • Angular 5 : Cannot read property 'subscribe' of undefined
  • How to create groups and grant different permissions in AWS Cognito in Serverless
  • Why not to consider models in REST API versioning?
  • React js - problem with proxy for web socket link in react
  • MongoDB query to find documents with variations
  • should I open/close different Postgres connections in one node endpoint? making this work with OOP
  • Publish a TypeScript Project to NPM without source
  • What is the difference between Child_process and Worker Threads?
  • Error: ENOENT: no such file or directory, scandir '.../node_modules/node-sass/vendor'
  • Updating all packages with Npm
  • Getting Users API access in nodejs AppEngine environment with Identity Aware Proxy
  • npm build gives "Ineffective mark-compacts near heap limit Allocation failed"
  • http-server with localhost:3000 gives ERR_INVALID_REDIRECT
  • Trying to figure a way to read all the files in a directory, re-create and write files programmatically
  • Problem using function in exported custom module in nodejs
  • Angular how to show live value of json object
  • What is GET/ error in node.js application?
  • UnhandledPromiseRejectionWarning: Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
  • Cost for retrieving user data using Firebase Admin Auth
  • how to treat special characters in variable names
  • How does one create a Stripe order with invoice?
  • Insert if not exists, if exists update
  • SyntaxError: await is only valid in async function with argon2
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk