不允许使用邮箱名称。服务器响应是:不允许来自“[email protected]”电子邮件地址的信封

问题描述 投票:0回答:7

我正在尝试使用 SMTP JS 在我的网站上制作联系表单。但是,当我将信息提交到表单中时,它无法输出错误消息:“SMTP JS 联系表单显示“不允许使用邮箱名称。服务器响应是:不允许使用来自“[电子邮件受保护]”电子邮件地址的信封。”

这是我的代码: HTML:

  <form onsubmit="send(); reset(); return false;">
            <input placeholder="First Name" required id="first-name"><br>
            <input placeholder="Last Name" required id="last-name"><br>
            <input placeholder="Email Adress" required id="email"><br>
            <button>Submit</button>
        </form>

SMTP JS

<script src="https://smtpjs.com/v3/smtp.js"></script>
<script>
var send = function() {
    Email.send({
    Host : "smtp.elasticemail.com",
    Username : "[email protected]",
    Password : "My Password",
    To : '[email protected]',
    From : document.getElementById("email").value,
    Subject : "New Signup!!!",
    Body : "And this is the body"
}).then(
  message => alert(message)
);
};
    </script>

我尝试将网站移动到 https 服务器以及本地主机。我该如何解决这个问题?

javascript html forms email smtp
7个回答
3
投票

我在使用过程中也遇到了同样的问题。我意识到如果 from 的值与 username 的值不同,则会给出该错误。所以我意识到或者更确切地说是推测,因为它实际上并不是从用户电子邮件发送的,这似乎是合理的,所以如果您需要获取用户电子邮件,只需将其与正文一起发送


1
投票

我也在测试 SMTP JS,并意识到发件人地址必须是实际的电子邮件。 elasticemail 的作用是退回邮件。 因此,如果您使用现有邮件尝试此操作,效果会很好。


0
投票

我在这里没有找到满意的答案,所以我会尝试解释什么对我有用:

在您的elasticemail电子邮件API设置中,您应该确保您注册并验证了您尝试用作发件人的电子邮件地址/域名。

默认情况下,您用于创建 elasticemail 帐户的电子邮件应在此处显示为“已验证”(对我来说是 gmail 和我的 gmail 地址)。因此,如果您在 smtpJS 配置中使用相同的电子邮件作为发件人,我猜它实际上应该在默认情况下工作。

但是,如果您尝试使用不同的电子邮件,那么您必须验证它以及域名(如果它是特定域名)。在 elasticemail 常见问题解答中对此进行了解释: https://help.elasticemail.com/en/articles/4934400-how-to-verify-your-domain

希望这有帮助


0
投票

需要进行两项更改,

  1. 您必须使用您创建的服务器的密码。 (不是您的 Elasticemail 帐户密码)
  2. 交换
    To
    From
    电子邮件,如下所示,

然后就可以了。

<script src="https://smtpjs.com/v3/smtp.js"></script>
<script>
var send = function() {
    Email.send({
    Host : "smtp.elasticemail.com",
    Username : "[email protected]",
    Password : "Password for the server created in the Elasticemail",
    From : '[email protected]',
    To : document.getElementById("email").value,
    Subject : "New Signup!!!",
    Body : "And this is the body"
}).then(
  message => alert(message)
);
};
</script>

0
投票

两步验证应该在您的gmail帐户上进行,然后在elasticemail网站上进行电子邮件验证。


0
投票

交换线路。会起作用的!


-1
投票
                    Host : "smtp.elasticemail.com",
                    Username : "[email protected]",//username from 
                    elasticemail
                    Password : "*******",//password from elasticemail SMTP
                    From : '[email protected]',//username from 
                    elasticemail
                    To: '[email protected]',//prefered email addresss.
                    ReplyFrom : document.getElementById("email").value,// user 
                    email displays here in the mail box
© www.soinside.com 2019 - 2024. All rights reserved.