简体   繁体   English

SmtpJS 不适用于 Elastic Email:“发送邮件失败。必须正确配置服务器。”

[英]SmtpJS not working with Elastic Email: "Failure sending mail. The server must be configured corectly."

After pressing send I get an error message saying:按发送后,我收到一条错误消息:

Failure sending mail. The server must be configured corectly.
function sendEmail() {
    Email.send({
        Host : "smtp.elasticemail.com 2525",
        Username : "myemail@gmail.com",
        Password : "PASTED ELASTIC SERVER PASWWORD",
        To : "randemail@gmail.com",
        From : document.getElementById("email").value,
        Subject : "New site email ",
        Body : "And this is the body"
    }).then(message => alert(message));
}

I thougth something wrong with the way I wrote the port, but wasn't able to find the answer.我认为我写端口的方式有问题,但找不到答案。

<main>
        <div class="container my-5">
            <form>
                <label for="name">Name:</label><input class="form-control" type="text" id="name" required />
                <label for="email">Email:</label><input class="form-control" type="email" id="email" required />
                <label for="subject">Subject:</label><input class="form-control" type="text" id="subject" required />
                <label for="message">Message:</label><textarea class="form-control" name="message" id="message" cols="30" rows="10"></textarea>
                <button type="submit" onclick="sendEmail(event)">
                    submit
                </button>
            </form>
        </div>
    </main>
    <footer>
        <!-- place footer here -->
    </footer>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://smtpjs.com/v3/smtp.js"></script>
    <script>
        function sendEmail(event) {
            event.preventDefault();

            var name = document.getElementById("name").value;
            var email = document.getElementById("email").value;
            var subject = document.getElementById("subject").value;
            var messages = document.getElementById("message").value;
            var body =
                "Name: " + name + "<br>Email: " + email + "<br>Message:" + messages;
            console.log("hello");
            Email.send({
                SecureToken: "7c90d80b-5966-4447-be77-c0121d3bdaf9",
                To: "reciever@gmail.com",
                From: "youremail@gmail.com",
                Subject: "sample na this",
                Body: body,
            }).then((message) => alert(message));
        }
    </script>

try my code you should put a preventDefault so it will not render试试我的代码,你应该放一个 preventDefault 这样它就不会渲染

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有使用弹性邮件接收带有 smtpjs 的电子邮件 - not receiving emails with smtpjs using elastic mail 通过 stmpjs 和弹性邮件发送电子邮件的问题 - Problem sending email through stmpjs and elastic mail 在 SMTPJS 中发送带有附件的 email 时无法读取 null 的属性“名称” - Cannot read property 'name' of null in Sending email with attachments in SMTPJS 注意:要发送记录分配通知,必须在电子邮件设置中配置 SMTP 服务器 - Note: To send record assignment notifications, an SMTP server must be configured in Email Settings 只有顶部下拉列表正在填充。 需要与其他下拉菜单相同的功能 - Only the top dropdown is populating corectly. Need the same functionality with other dropdowns as well 如何在 javascript 中将生成的 pdf 附加到 smtpjs 邮件 - How to attach a generated pdf to a smtpjs mail in javascript SmtpJs API 不工作! 有没有办法使用带有 JavaScript 或 JQuery 的 SMTP 服务器发送电子邮件 - SmtpJs API not working! is there any way to send emails using SMTP server with JavaScript or JQuery 使用 smtpJs 发送电子邮件时出错 (JavaScript) - Error when using smtpJs to send email (JavaScript) React - 使用 wp_mail 发送电子邮件 - React - sending an email using wp_mail Jq在IE8上没有正常工作 - Jq that are not working corectly on IE8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM