简体   繁体   English

如何向邮件地址提交表格

[英]How to submit form to mail address

I'm creating my portfolio and I have implemented a contact form. 我正在创建我的投资组合,并且已经实施了联系表格。

I would to receive visitors messages in my gmail. 我会用Gmail接收访客消息。 I don't find on the web how to do it in Angular 2/4. 我在网上找不到如何在Angular 2/4中进行操作。

Should I add a Back end site to do that? 我应该添加一个后端站点来做到这一点吗?

<div class="contactcard">
    <md-card class="mdcardcontact">
        <md-card-header style="background-color: black; width:100%"></md-card-header>
        <div>
            <md-card-content>
                <form [formGroup]="form" class="form">
                    <div>
                        <md-input-container class="full-width">
                            <input mdInput type="text" formControlName="name" placeholder="Votre nom">
                        </md-input-container>
                    </div>
                    <div>
                        <md-input-container class="full-width">
                            <input mdInput type="text" formControlName="email" placeholder="Votre adressse mail">
                            <md-error *ngIf="form.get('email').hasError('pattern') ">
                                Votre mail n'est pas valid
                            </md-error>
                        </md-input-container>
                    </div>
                    <div>
                        <md-input-container class="full-width">
                            <input mdInput type="tel" formControlName="telephone" placeholder="Votre numéro de téléphone">
                            <md-error *ngIf="form.get('email').hasError('pattern') ">
                                Votre mail n'est pas valid
                            </md-error>
                        </md-input-container>
                    </div>
                    <div>
                        <md-input-container class="full-width">
                            <textarea mdInput type="text" formControlName="message" placeholder="Votre message" style="height:200px; "></textarea>
                        </md-input-container>
                    </div>
                    <button md-fab class="send-button">
                        <md-icon>send</md-icon>
                    </button>
                </form>
            </md-card-content>
        </div>
    </md-card>
</div>

If I understand correctly you're trying to send an email using Javascript on the front end, which is not possible (see also this question ). 如果我理解正确,则您尝试在前端使用Javascript发送电子邮件,这是不可能的(另请参见此问题 )。 You're going to have to set up a server or use a 3rd party client for this. 您将必须为此设置服务器或使用第三方客户端。

You will need a Server-side Language to do this (PHP, C#, Java, Python...). 您将需要服务器端语言来执行此操作(PHP,C#,Java,Python ...)。 In sending mail to the client some SMTP protocols have to be executed and this in my opinion at the moment has to be done on the server.So collect user information in your contact form and pass it to the method on the server to transport it. 在向客户端发送邮件时,必须执行一些SMTP协议,目前我认为必须在服务器上完成此操作,因此请以联系方式收集用户信息,并将其传递给服务器上的方法以进行传输。

You need some sort of backend script to do that for you. 您需要某种后端脚本来为您执行此操作。 Then you send required data to this script from your angular app. 然后,您可以从角度应用程序将所需数据发送到此脚本。

如果可以将nodemailer和sendgrid传递回服务器端,则可以使用

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM