dongqiancui9194 2016-03-06 22:48
浏览 48

使用PHPmailer从网站发送消息时遇到错误

I am trying to fix the error but I can't. There are lot of stuff about PHPmailer on internet I tried it but my website is not sending messages. Please fix the error. I am pasting my code. Please let me know other methods to send message also.

<div class="row">
    <div class="col-lg-8">
        <div class="boxed-grey">
            <form id="contact-form">
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <form action="ContactFormHandler.php"
                                  method="post">
                                <label for="name">
                                    Name</label>
                                <input type="text" class="form-control"
                                       id="name" placeholder="Enter name" required="required" />
                        </div>
                        <div class="form-group">
                            <label for="email">
                                Email Address</label>
                            <div class="input-group">
                                 <span class="input-group-addon"><span
                                         class="glyphicon glyphicon-envelope"></span>
                                </span>
                                <input type="email"
                                       class="form-control" id="email" placeholder="Enter email"
                                       required="required" /></div>
                        </div>

                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="name">
                                Message</label>
                            <textarea name="message" id="message"
                                      class="form-control" rows="9" cols="25" required="required"
                                      placeholder="Message"></textarea>
                        </div>
                    </div>
                    require("path of phpmailer folder
                    \class.phpmailer.php");

                    $mail = new PHPMailer();

                    $mail->IsSMTP();
                    $mail->Host = "mymail.domain.com";
                    $mail->SMTPAuth = true;
                    $mail->Username = "myemail";
                    $mail->Password = "psswrd";

                    $mail->From = "you@domain.com";
                    $mail->FromName = "Your Name";
                    $mail->AddReplyTo("you@domain.com");
                    $mail->AddAddress("user@domain.com");
                    $mail->IsHTML(true);
                    $mail->Subject = "Test message sent using the
                    PHPMailer component";
                    $mail->Body = "This is a test message.";
                    $mail->Send();
                    ?>
                    <div class="col-md-12">
                        <button type="submit" class="btn btn-skin
pull-right" id="btnContactUs">
                            Send Message</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
  • 写回答

2条回答 默认 最新

  • dtlc84438 2016-03-06 22:53
    关注

    your name and email inputs do not have a name attribute listed for them so will not send any data in the form submission.

    you need to alter them as follows:

    <input type="text" class="form-control" name="name" id="name" placeholder="Enter name" required="required" />
    
    
    <input type="email" class="form-control" name="email"  id="email"  placeholder="Enter email" required="required" />
    

    This may not be the issue that causing the error but it will cause an issue.

    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器