通过收集用户通过表单提供的信息来向所有者发送电子邮件? [英] send email to owner by collecting information provided by user through form?

查看:156
本文介绍了通过收集用户通过表单提供的信息来向所有者发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计了用户输入表单,用于收集用户名,电子邮件地址,主题和消息. 我已经验证了所有将这些元素存储在变量中的元素. 现在,我需要通过电子邮件将此信息发送给所有者. 如何在localhost(too)中解决此问题?

I had designed user input form that collects user name, email address, subject and message. I had verified all elements stored these element in variable. Now I need to send this information to the owner via email. How can I solve this problem in localhost(too)?

  1. 如何发送电子邮件给所有者?
  2. 如何添加所有信息,以便以后可以在所有者电子邮件中找回或更改它.

contact.php

<form action="contact_ok.php" method="post"  autocomplete="on">
<p>
    <label for="username"> Name <span class="required">*</span></label>
    <input type="text" name="username" required="TRUE"/>
</p>
<p> 
    <label for="usermail"> E-mail address <span class="required">*</span></label>
    <input type="email" name="usermail"required="TRUE"/>
</p>
<p>
    <label for="subject"> Subject </label>
    <input type="text" name="subject" required="TRUE" />
</p>
<p>
    <label for="message"> Message  <span class="required">*</span></label>
    <textarea name="msg" required="TRUE" ></textarea>
</p> 
<input type="submit" name="submit mail"/>   
</form>

contact_ok.php

<?php
$name = addslashes($_POST['username']);
$uml = addslashes($_POST['usermail']);
$sub = addslashes($_POST['subject']);
$msg =addslashes($_POST['msg']);
//sending mail to owner
$to ='owner@gmail.com';
//enter input information in array ******
//send email
mail($to,$sub,$msg);
?>

对于发送邮件,我读到了有关PHP邮件程序的信息,但是我很难理解.我还研究了 SO 上的线程数量还不够. 2.对于存储所有元素,我尝试首先使用$msg=str_split($msg)将消息转换为数组 并使用push_array($msg)推送所有其他信息,并使用print_r($msg,TRUE)对其进行更改,但这不起作用.

For sending mail I read about PHP mailer but I found hard to understand. Also I studied this thread on SO it is also not sufficient. 2.For storing all elements I tried to convert message firstly to array by using $msg=str_split($msg) and push all other information by using push_array($msg) and change it by using print_r($msg,TRUE) but it does not work.

推荐答案

有不同的方法:

1)您可以使用 PHP MAILER 库发送电子邮件.因此,该库完全基于SMTP.您必须指定第三方SMTP服务和凭据.您可以通过gmail,yahoo等发送电子邮件.通过使用该库.该库将处理有价证券,标头等,并且非常易于使用.

1) You can use PHP MAILER library to send Email. So this library is totally based on SMTP . You have to specify your third party SMTP services and credentials. You can send email through gmail, yahoo etc . by using this library. This library will take care about securities, headers etc and very easy to use.

2)我不推荐的另一种方法是安装自己的postfix.配置所有内容并发送电子邮件.它非常耗时,您必须添加各种级别的身份验证,例如SPF,DMARC等.

2) Another way which is not recommend by me is install your own postfix. Configure all things and send an email. Its very time consuming and you have to add various level of authentication like SPF, DMARC etc.

我想建议您使用PHP Mailer集成您的SMTP服务并启动Mailing.

I would like to recommend you to go with PHP Mailer integrate yous SMTP service and start Mailing.

这篇关于通过收集用户通过表单提供的信息来向所有者发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆