如何通过web-server上的codeigniter而不是通过local-host

时间:2016-07-15 21:18:11

标签: php forms codeigniter email codeigniter-3

关于通过本地主机发送邮件和联系表单数据有很多答案,我成功地做到了这一点。但是当我在服务器上的网站(hostinger)时,我会遇到问题。

我想在我的电子邮件中发送联系表单的所有数据,我会收到有关电子邮件的联系表单数据,但用户电子邮件字段数据不在电子邮件中,如果我在表单上传递电子邮件字段数据,那么&# 39; s成功发送电子邮件但邮件不在邮件帐户中,并且没有显示任何错误,并且还在控制台显示请求上成功发送。

如果我对用户电子邮件字段数据发表评论,那么每件事情都很好,但是通过用户电子邮件,我在电子邮箱上什么都没有。 如果任何人知道如何传递电子邮件价值,那么请求你的知识。我对这个问题非常厌倦,我在这个问题上花了2天时间仍然没有任何线索。

我的代码是 - application / view / email_temp.php -

<html style="background:#5D849E;background-size:cover;height:100%;">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    </head>
    <body>
        <div>
            <div style="background-color:rgba(72,72,72,0.4);padding-left:35px;padding-right:35px;padding-top:35px;padding-bottom:50px;width:650px;float:left;left:50%;position:absolute;margin-top:30px;margin-left:-300px;-moz-border-radius:7px;-webkit-border-radius:7px;">
                  <form>
                    <h1 align="center" style="color:#3c3c3c;font-family:Helvetica,Arial,sans-serif;font-weight:500;font-size:28px;border-radius:0;line-height:22px;background-color:#fbfbfb;padding:13px 13px 13px 54px;margin-bottom: 10px;width:100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box;    -ms-box-sizing: border-box; box-sizing: border-box; border: 3px solid rgba(0,0,0,0);"><b>New one Contact You!</b>
                    </h1><br>
                        <table align="left" style="color:#3c3c3c;font-family:Helvetica,Arial,sans-serif;font-weight:500;font-size:22px;border-radius:0;line-height:22px;background-color:#fbfbfb;padding:13px 13px 13px 54px;margin-bottom: 10px;width:100%;    -webkit-box-sizing: border-box; -moz-box-sizing: border-box;    -ms-box-sizing: border-box; box-sizing: border-box;border: 3px solid rgba(0,0,0,0);">
                          <tbody>
                            <tr height="50px;"><th align="left">Company Name : </th><td><?php echo $cname;?></td></tr>
                            <tr height="50px;"><th align="left">Name : </th><td><?php echo $name;?></td></tr>

                            <tr height="50px;">
                              <th align="left">Phone : </th><td><?php echo $phone;?></td>
                            </tr>
                                <tr height="50px;">
                              <th align="left">Address : </th><td><?php echo $address;?></td>
                            </tr>
                            <tr height="50px;">
                              <th align="left">State : </th><td><?php echo $state;?></td>
                            </tr>
                            <tr height="50px;">
                              <th align="left">Contry : </th><td><?php echo $country;?></td>
                            </tr>
                            <tr height="50px;">
                              <th align="left">Accreditation For which Standard : </th><td><?php echo $accre;?></td>
                            </tr>
                            <tr height="50px;">
                              <th align="left">Describe Your requirements : </th><td><?php echo $requir;?></td>
                            </tr>
                            <tr height="50px;">
                              <th align="left">Email : </th><td><?php echo $name;?></td>
                            </tr>
                          </tbody>
                        </table>
                </form>
            </div>
        </div>
    </body>
</html>

应用/控制器/ ContactUs.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ContactUs extends CI_Controller {
        function __construct() { parent::__construct(); $this->load->helper('url'); $this->load->library('email'); }
public function contactMailSend()
    {          
            $data = array(
        'cname' => $this->input->post('contact_cname'),
        'name' => $this->input->post('contact_name'),
        'userEmail' => $this->input->post('cemail'),
        'phone' => $this->input->post('contact_phone'),
        'address' => $this->input->post('contact_address'),
        'state' => $this->input->post('contact_state'),
        'country' => $this->input->post('contact_country'),
        'accre' => $this->input->post('contact_accre'),
        'requir' => $this->input->post('contact_requir')
        );
       $subject="Urgent || New Persone || Contact You";
       $this->load->library('email');
       $this->email->set_newline("\r\n");
       $this->email->from('abc@gmail.com');
       $this->email->to('abc@gmail.com');
       $this->email->subject($subject);
       $body=$this->load->view('email_temp', $data, true);
       $this->email->message($body);       
       if($this->email->send())
       {
           echo "Mail send successfully";
       }
       else
       {
           echo "Not send mail";
        }
}
?>

应用/视图/ contact.php

<!-- Link for toaster -->
<!-- <link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet" /> -->
<!-- End -->

<!-- Css for toaster -->
<style type="text/css">

#toast-container > .toast {
    background-image: none !important;
}

#toast-container > .toast:before {
    position: fixed;
    font-family: FontAwesome;
    font-size: 24px;
    line-height: 18px;
    float: left;
    color: #FFF;
    padding-right: 0.5em;
    margin: auto 0.5em auto -1.5em;
}        
#toast-container > .toast-warning:before {
    content: "\f003";
}
#toast-container > .toast-error:before {
    content: "\f001";
}
#toast-container > .toast-info:before {
    content: "\f005";
}
#toast-container > .toast-success:before {
    content: "\f003";
}

</style>
<!-- End -->    

<section id="inner-headline">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <ul class="breadcrumb">
                    <li><a href="<?php echo base_url();?>"><i class="fa fa-home"></i></a><i class="icon-angle-right"></i></li>
                    <li>Contact Us<i class="icon-angle-right"></i></li>
                </ul>
            </div>
        </div>
    </div>
</section>

<div class="container">

            <div class="row">
                <div class="col-lg-12">

                <div class="col-md-8">

                    <h1>Contact Us </a></h1>
                    <hr>    

<form id="contact-form" onsubmit="return validate();" method="post" action="<?php base_url(); ?>ContactUs/contactMailSend" role="form">

    <div class="messages"></div>

    <div class="controls">

        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label for="contact_cname">Companyname *</label>
                    <input id="contact_cname" type="text" name="contact_cname" class="form-control" placeholder="Please enter your Company Name *" required="required" data-error="Firstname is required.">
                    <div class="help-block with-errors"></div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label for="contact_name">Name *</label>
                    <input id="contact_name" type="text" name="contact_name" class="form-control" placeholder="Please enter your Name *" required="required" data-error="Lastname is required.">
                    <div class="help-block with-errors"></div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label>Email *</label>
                    <input type="email" name="cemail" class="form-control" placeholder="Please enter your email *">
                    <div class="help-block with-errors"></div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label for="contact_phone">Phone</label>
                    <input id="contact_phone" type="tel" name="contact_phone" class="form-control" placeholder="Please enter your phone">
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label for="contact_address">Address *</label>
                    <input id="contact_address" type="text" name="contact_address" class="form-control" placeholder="Please enter your Address *" required="required" data-error="Firstname is required.">
                    <div class="help-block with-errors"></div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label for="contact_state">State *</label>
                    <input id="contact_state" type="text" name="contact_state" class="form-control" placeholder="Please enter State *" required="required" data-error="Lastname is required.">
                    <div class="help-block with-errors"></div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label for="contact_country">Country *</label>
                    <input id="contact_country" type="text" name="contact_country" class="form-control" placeholder="Please enter Country *" required="required" data-error="Firstname is required.">
                    <div class="help-block with-errors"></div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label for="contact_accre">Accreditation For which Standard *</label>
                    <input id="contact_accre" type="text" name="contact_accre" class="form-control" placeholder="Please enter enquiry standard *" required="required" data-error="Lastname is required.">
                    <div class="help-block with-errors"></div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="form-group">
                    <label for="contact_requir">Describe Your requirements *</label>
                    <textarea id="contact_requir" name="contact_requir" class="form-control" placeholder="Describe Your requirements *" rows="4" required="required" data-error="Please,leave us a describtion of requirements."></textarea>
                    <div class="help-block with-errors"></div>
                </div>
            </div>
            <div class="col-md-12">
                <input type="submit" class="btn btn-success btn-send" value="Send message">
            </div>
        </div>
    </div>

</form>
</div>
<br><br><br>
    <div class="col-md-1"></div>
    <div class="col-md-3">
        <h3>Mail Us -</h3>
        <a href="mailto:iafuk.org@gmail.com"><strong>iafuk.org@gmail.com</strong></a>
        <br><br>
        <h3>Address -</h3>
        <address>
            <strong>IAF-UK Akkreditering Forum Limited</strong><br>
             Suite 20, 196 Rose Street<br>
             Edinbugh, Eh2 4AT, UK 
        </address>      
        <strong>Phone - (123) 364-7562 / (123) 526-6892</strong>    
    </div>

</div>
</div>
</div>

assets / js / validation.js - 点击按钮时用于烤面包机

function validate() {

$cname = document.getElementById('contact_cname');
$name = document.getElementById('contact_name');

$phone = document.getElementById('contact_phone');
$address = document.getElementById('contact_address');
$state = document.getElementById('contact_state');
$country = document.getElementById('contact_country');
$accre = document.getElementById('contact_accre');
$requir = document.getElementById('contact_requir');
if($cname.value == '' || $cname.value == null || $name.value == '' || $name.value == null || $phone.value == '' || $phone.value == null) {
    return false;
}
else {
    showToast();
return true;

}
}

0 个答案:

没有答案