Sending email using Sendmail example (here

I am trying to send email using netlify functions as mentioned here in this example.

When i deploy this function on localhost, i am able to send email, but once i deployed it on netlify server, it fails with timeout exception (I am aware of 10 seconds default timeout frame). but i feel the email API(function) take more than 10 seconds to send a mail.

Please let us know, Is it really possible to send email thorough netlify function, if yes, then how can we correct it.

Thanks in advance.

Hi @shankar.krishnan1, welcome to the Community.

Can you point to a live example of this function? I’ve not used the sendmail package myself so I don’t know if it does take longer than 10 seconds to complete. If it does, then your only option would be upgrade your site to ‘Functions Level 1’ and letting us know so we can increase the timelimit of your function (up to 28 seconds).

Let me know if that makes sense.

Hi Dennis,
Thank you for your reply,
Here is an example of function.

const sendMail = require('sendmail')()

exports.handler = function (event, context, callback) {
    const payload = JSON.parse(event.body || {});

function sendEmail(payload, callback ) {
        from: 'no-reply@<company-domain>.com',
        to: '<user-emailid>@<company-domain>.com',
        subject: 'test sendmail',
        text: JSON.stringify(payload)
    }, function (e) {
        if (e) {
            callback(null, {
              statusCode: 500,
              body: e.message
          else {
            callback(null, {
                statusCode: 200,
                body: `Mail Sent successfully!`,

API Response:-
{"errorMessage":"2018-12-17T02:49:11.602Z 4f290cff-01a6-11e9-934d-9f4eca498414 Task timed out after 10.01 seconds"}

When i deploy this code on any server, i get response(200) from API in 2-3 seconds(success with email delivered), but netlify fails with timeout,
Another scenario, when i deploy netlify function in local, using netlify-lambda, it works fine (response(200) within 2 seconds, success with email delivered), but when i deploy it on production, it fails with timeout.

Please let me know if i have answered your question correctly.

Hi! I actually meant if you have a live deployed version of your function so I can check our logs to see why the function is timing out.

That said, perhaps your function is not getting to the callback before the 10 second time limit. I recommend that you try adding some console.logs to help you debug your function. You can then take a look at the logs in your site’s UI.

Hi Dennis,
I can forward you the deployed function’s link, if you can share your email id.
Thank you

He is asking for you to post the function path here - we don’t usually handle DM’s, we work in public so that others can learn :slight_smile: If you have a paid team plan (Pro or higher), you are welcome to instead send mail to our helpdesk (, sent from your login email shown at for private help.