evershopcommerce / evershop

πŸ›οΈ NodeJS E-commerce Platform
https://evershop.io/
GNU General Public License v3.0
4.46k stars 1.23k forks source link

[BUG] Resend extension not working #659

Closed dheeth closed 1 day ago

dheeth commented 1 week ago

Describe the bug I have enabled resend extension for transactional emails but I am not getting any order placed email or any email right now.

To Reproduce Steps to reproduce the behavior:

  1. Run npm install @evershop/resend
  2. Contents in .env file placed at root of project RESEND_API_KEY=re_xxxxx
  3. My config/default.json

    {
    "themeConfig": {
      "copyRight": "Β© 2024 Shopscape. All Rights Reserved.",
      "logo": {
            "alt": "shopscape logo",
            "src": "/images/logo.png",
            "width": 40,
            "height": 50
        },
      "headTags": {
            "links": [
                {
                    "rel": "icon",
                    "href": "/images/favicon.ico"
                }
            ]
        }
    },
    "catalog": {
    "product": {
      "image": {
        "listing": {
          "height": 720,
          "width": 1080
        },
        "single": {
          "height": 1080,
          "width": 1980
        },
        "thumbnail": {
          "height": 500,
          "width": 500
        }
      }
    },
    "showOutOfStockProduct": true
    },
    "shop": {
    "currency": "INR",
    "language": "en",
    "weightUnit": "kg"
    },
    "system": {
    "extensions": [
            {
                "name": "razorpay",
                "resolve": "node_modules/evershop-razorpay",
                "enabled": true
            },
        {
        "name": "product_review",
        "resolve": "node_modules/@evershop/product_review",
        "enabled": true,
        "priority": 10
          },
          {
        "name": "resend",
        "resolve": "node_modules/@evershop/resend",
        "enabled": true,
        "priority": 1
        }
    ]
    },
    "resend": {
    "from": "Shopscape Support support@shopscape.co",
    "events": {
      "order_placed": {
        "subject": "Order Confirmation",
        "enabled": true,
        "templatePath": "config/emails/order_confirmation.html"
      },
      "reset_password": {
        "subject": "Reset Password",
        "enabled": true,
        "templatePath": "config/emails/reset_password.html"
      },
      "customer_registered": {
        "subject": "Welcome to EverShop",
        "enabled": true,
        "templatePath": "config/emails/welcome.html"
      }
    }
    }
    }

    My config/emails/order_confirmation.html

    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html dir="ltr" lang="en">
    
    <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    </head>
    <div style="display:none;overflow:hidden;line-height:1px;opacity:0;max-height:0;max-width:0">Your order has been confirmed. Thanks for shopping with us.<div>Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€Β β€Œβ€‹β€</div>
    </div>
    
    <body style="background-color:#ffffff;font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Oxygen-Sans,Ubuntu,Cantarell,&quot;Helvetica Neue&quot;,sans-serif">
    <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="max-width:100%;margin:10px auto;width:600px;border:1px solid #E5E5E5">
      <tbody>
        <tr style="width:100%">
          <td>
            <hr style="width:100%;border:none;border-top:1px solid #eaeaea;border-color:#E5E5E5;margin:0" />
            <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="padding:40px 74px;text-align:center">
              <tbody>
                <tr>
                  <td><img alt="Shopscape" height="30" src="https://shopscape.co/images/logo.png" style="display:block;outline:none;border:none;text-decoration:none;margin:auto" width="30" />
                    <h1 style="font-size:32px;line-height:1.3;font-weight:700;text-align:center;letter-spacing:-1px">Thanks for shopping with us.</h1>
                    <hr style="width:100%;border:none;border-top:1px solid #eaeaea;border-color:#E5E5E5;margin:0" />
                    <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="padding-left:40px;padding-right:40px;padding-top:22px;padding-bottom:22px">
                      <tbody>
                        <tr>
                          <td>
                            <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="display:inline-flex">
                              <tbody style="width:100%">
                                <tr style="width:100%">
                                  <td data-id="__react-email-column" style="width:170px">
                                    <p style="font-size:14px;line-height:2;margin:0;font-weight:bold">Order Number</p>
                                    <p style="font-size:14px;line-height:1.4;margin:12px 0 0 0;font-weight:500;color:#6F6F6F">#{{order_number}}</p>
                                  </td>
                                  <td data-id="__react-email-column">
                                    <p style="font-size:14px;line-height:2;margin:0;font-weight:bold">Order Date</p>
                                    <p style="font-size:14px;line-height:1.4;margin:12px 0 0 0;font-weight:500;color:#6F6F6F">{{created_at}}</p>
                                  </td>
                                </tr>
                              </tbody>
                            </table>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                  </td>
                </tr>
              </tbody>
            </table>
            <hr style="width:100%;border:none;border-top:1px solid #eaeaea;border-color:#E5E5E5;margin:0" />
            <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="padding-left:40px;padding-right:40px;padding-top:22px;padding-bottom:22px">
              <tbody>
                <tr>
                  <td>
                    <p style="font-size:15px;line-height:2;margin:0;font-weight:bold">Shipping to: {{shipping_address.full_name}}</p>
                    <p style="font-size:14px;line-height:2;margin:0;color:#747474;font-weight:500">{{shipping_address.address_1}}, {{shipping_address.city}}, {{shipping_address.province_name}} {{shipping_address.postcode}}</p>
                  </td>
                </tr>
              </tbody>
            </table>
            <hr style="width:100%;border:none;border-top:1px solid #eaeaea;border-color:#E5E5E5;margin:0" />
            <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="padding-left:40px;padding-right:40px;padding-top:40px;padding-bottom:40px">
              <tbody>
                <tr>
                  <td>
                    <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation">
                      <tbody style="width:100%">
                        {{#each items}}
                          <tr style="width:100%">
                            <td data-id="__react-email-column"><img alt="{{this.product_name}}" src="{{this.thumbnail}}" style="display:block;outline:none;border:none;text-decoration:none;float:left" width="100px" /></td>
                            <td data-id="__react-email-column" style="vertical-align:top;padding-left:12px">
                              <p style="font-size:14px;line-height:2;margin:0;font-weight:500">{{this.product_name}}</p>
                              <p style="font-size:14px;line-height:2;margin:0;color:#747474;font-weight:500">{{this.qty}} | {{this.final_price}}</p>
                            </td>
                          </tr>
                        {{/each}}
                      </tbody>
                    </table>
                  </td>
                </tr>
              </tbody>
            </table>
            <hr style="width:100%;border:none;border-top:1px solid #eaeaea;border-color:#E5E5E5;margin:0" />
            <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="padding-left:40px;padding-right:40px;padding-top:40px;padding-bottom:40px">
              <tbody>
                <tr>
                  <td>
                    <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation">
                      <tbody style="width:100%">
                        <tr style="width:100%">
                          <td data-id="__react-email-column">Total</td>
                          <td data-id="__react-email-column" style="vertical-align:top;padding-left:12px">
                            <p style="font-size:14px;line-height:2;margin:0;font-weight:500">{{grand_total_text}}</p>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                  </td>
                </tr>
              </tbody>
            </table>
            <hr style="width:100%;border:none;border-top:1px solid #eaeaea;border-color:#E5E5E5;margin:0" />
            <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="padding-left:20px;padding-right:20px;padding-top:20px;background-color:#F7F7F7">
              <tbody>
                <tr>
                  <td>
                    <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation">
                      <tbody style="width:100%">
                        <tr style="width:100%">
                          <p style="font-size:14px;line-height:24px;margin:16px 0;padding-left:20px;padding-right:20px;font-weight:bold">Get Help</p>
                        </tr>
                      </tbody>
                    </table>
                  </td>
                </tr>
              </tbody>
            </table>
            <hr style="width:100%;border:none;border-top:1px solid #eaeaea;border-color:#E5E5E5;margin:0" />
            <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="padding-top:22px;padding-bottom:22px">
              <tbody>
                <tr>
                  <td>
                    <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation">
                      <tbody style="width:100%">
                        <tr style="width:100%">
                          <p style="font-size:32px;line-height:1.3;margin:16px 0;font-weight:700;text-align:center;letter-spacing:-1px">Shopscape.co</p>
                        </tr>
                      </tbody>
                    </table>
                    <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="width:370px;margin:auto;padding-top:12px">
                      <tbody style="width:100%">
                        <tr style="width:100%">
                          <td align="center" data-id="__react-email-column"><a href="/electronics/power-banks" style="color:#000;text-decoration:none;font-weight:500" target="_blank">Power Banks</a></td>
                          <td align="center" data-id="__react-email-column"><a href="/electronics/neckbands" style="color:#000;text-decoration:none;font-weight:500" target="_blank">Neckbands</a></td>
                          <td align="center" data-id="__react-email-column"><a href="/electronics/wireless-speakers" style="color:#000;text-decoration:none;font-weight:500" target="_blank">Bluetooth Speakers</a></td>
                          <td align="center" data-id="__react-email-column"><a href="/electronics/mobile-chargers" style="color:#000;text-decoration:none;font-weight:500" target="_blank">Mobile Chargers</a></td>
                        </tr>
                      </tbody>
                    </table>
                  </td>
                </tr>
              </tbody>
            </table>
            <hr style="width:100%;border:none;border-top:1px solid #eaeaea;border-color:#E5E5E5;margin:0;margin-top:12px" />
            <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="padding-top:22px;padding-bottom:22px">
              <tbody>
                <tr>
                  <td>
                    <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation">
                      <tbody style="width:100%">
                        <tr style="width:100%">
                          <p style="font-size:13px;line-height:24px;margin:0;color:#AFAFAF;text-align:center;padding-top:10px;padding-bottom:10px">Reply to this email if you have any questions.</p>
                        </tr>
                      </tbody>
                    </table>
                    <table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation">
                      <tbody style="width:100%">
                        <tr style="width:100%">
                          <p style="font-size:13px;line-height:24px;margin:0;color:#AFAFAF;text-align:center">Β© 2024 Shopscape. All Rights Reserved.</p>
                        </tr>
                      </tbody>
                    </table>
                  </td>
                </tr>
              </tbody>
            </table>
          </td>
        </tr>
      </tbody>
    </table>
    </body>



**Expected behavior**
As soon as order is confirmed, email should be received by the person who received the order but no email is received. Even resent apis are not even hit as there is nothing in API logs on resend.

**Background**:

- NodeJS Version - v20.17.0
- Postgres Version - 14.13
- EverShop Version - latest
- OS: Ubuntu
- Browser: Brave
dheeth commented 5 days ago

@treoden Any help to debug this would be really appreciated

treoden commented 5 days ago

Hi @dheeth ,

Is reset_password working?

And for order_placed event, Can I know if you are using a customized payment method?

dheeth commented 5 days ago

No not even reset_password is working. Also, for order_placed event yes, I am using customized payment method. All the orders are getting order placed or payment status paid etc. events properly in admin panel.

dheeth commented 5 days ago

I don't see any API logs or emails in resend dashboard as well, seems like it doesn't reach the API

dheeth commented 5 days ago

@treoden Please help, this is the only pending thing in my e-commerce website complete happy flow

treoden commented 2 days ago

Hi @dheeth ,

If I am not mistaken, by default Resend only sends email to the account email before your account got verified.

Can you check again

dheeth commented 2 days ago
Screenshot 2024-11-11 at 11 50 43β€―AM

I can see that the domain is verified on resend if this is what you are talking about @treoden

treoden commented 2 days ago

Can you let me know the version of EverShop and the resend extension?

dheeth commented 1 day ago

Fixed it by converting these things with python (Shell and python are the only languages I know) "from": "Shopscape Support support@shopscape.co" This was the issue. It had to be "from": "Shopscape Support <support@shopscape.co>" Angular braces were missing

As soon as I ran it with python, it gave me the error from resend module about the angular braces. Error was the only thing needed to debug, extensions should have the option to print debug or error logs