2017-07-27 3 views
0

Ich versuche Codeigniter E-Mail-Klasse, aber es funktioniert nicht oder Mag sein, ich Fehler bei der Konfiguration oder etwas anderes zu machen. Bitte beheben Sie es und informieren Sie mich jemanden, was ich tun soll. Ich habe ein Problem mit der Codeigniter-E-Mail-Klasse.Codeigniter E-Mail-Klasse funktioniert nicht

Dies ist der Bildschirm nachdem die Formulardaten an die Steuerung zu senden.

This is the screenshot after sending the form data to the controller

Ausblick:

   <h4>Send Your Feedback</h4> 
       <form action="<?php echo base_url('front/feedBack') ?>" enctype="multipart/form-data" method="post" class="form-horizontal"> 
        <div class="form-group"> 
         <label for="Name" class="col-sm-3 control-label">Name<span>*</span></label> 
         <div class="col-sm-9"> 
          <input type="text" name="senderName" class="form-control" id="Name" placeholder="Name"> 
         </div> 
        </div> 
        <div class="form-group"> 
         <label for="Phone" class="col-sm-3 control-label">Phone no<span>*</span></label> 
         <div class="col-sm-9"> 
          <input type="text" name="senderPhone" class="form-control" id="Phone" placeholder="Phone no"> 
         </div> 
        </div> 
        <div class="form-group"> 
         <label for="Email" class="col-sm-3 control-label">Email<span>*</span></label> 
         <div class="col-sm-9"> 
          <input type="text" name="senderEmail" class="form-control" id="Email" placeholder="Email"> 
         </div> 
        </div> 
        <div class="form-group"> 
         <label for="Subject" class="col-sm-3 control-label">Subject</label> 
         <div class="col-sm-9"> 
          <input type="text" name="senderSubject" class="form-control" id="Subject" placeholder="Subject"> 
         </div> 
        </div> 
        <div class="form-group"> 
         <label for="Message" class="col-sm-3 control-label">Message<span>*</span></label> 
         <div class="col-sm-9"> 
          <textarea name="senderMsg" class="form-control" id="Message" cols="30" rows="5" placeholder="Message"></textarea> 
         </div> 
        </div> 
        <div class="form-group"> 
         <label for="inputPassword" class="col-sm-3 control-label"></label> 
         <div class="col-sm-9"> 
          <button type="submit" class="btn btn-default btn-lg btn-block">Send Message</button> 
         </div> 
        </div> 
       </form> 

Controller:

public function feedBack() 
{ 
    $this->load->library('email'); 

    $config['protocol'] = 'smtp'; 

    $config['smtp_host'] = 'host8.registrar-servers.com'; 

    $config['smtp_port'] = '465'; 

    $config['smtp_timeout'] = '30'; 

    $config['smtp_user'] = '[email protected]'; 

    $config['smtp_pass'] = 'myPass'; 

    $config['charset'] = 'utf-8'; 

    $config['crlf'] = '\r\n';  //should be "\r\n" 
    $config['newline'] = '\r\n'; //should be "\r\n" 

    $config['mailtype'] = 'html'; // or html 

    $config['validation'] = TRUE; // bool whether to validate email or not 

    $this->email->initialize($config); 



    $senderName = $this->input->post('senderName'); 
    $senderPhone = $this->input->post('senderPhone'); 
    $senderEmail = $this->input->post('senderEmail'); 
    $senderSubject = $this->input->post('senderSubject'); 
    $senderMsg = $this->input->post('senderMsg'); 

    $this->email->from($senderEmail, $senderName); 
    $this->email->to('[email protected]'); 


    $this->email->subject($senderSubject); 

    $this->email->message($senderMsg); 

    if($this->email->send()) { 
     echo "Success!"; 
     //return true; 
    } else { 
     echo "Failure!"; 
     //return false; 
    } 

} 

Antwort

0

Versuchen Sie folgendes:

$config = Array(
       'protocol' => 'smtp', 
       'smtp_host' => '[email protected]', 
       'smtp_port' => 2525, 
       'smtp_user' => 'gmailusername', 
       'smtp_pass' => 'password', 
       'mailtype' => 'html', 
       'charset' => 'iso-8859-1' 
      ); 
    $config['wordwrap'] = TRUE; 
    $config['mailtype'] = 'html'; 

    $THIS->email->initialize($config); 
    $THIS->email->set_newline("\r\n"); 
    $body = str_replace(array('{LOGO_IMAGE}'),array($logo_image),$body); 

    $body.= email_footer(); 
    $body = '<div style="width:700px;float:left;">'.$body.'</div>'; 
    if (!empty($from)) 
    { 
     $from_name = !empty($from_name) ? $from_name : SITE_NAME; 
     $from = !empty($from) ? $from : '[email protected]';   
     $THIS->email->from($from, $from_name); 
    } 
    else 
    { 
     $THIS->email->from('[email protected]', $from_name); 
    } 
    if (!empty($to)) 
    { 
     $THIS->email->to($to); 
    } 
    if (!empty($cc)) 
    { 
     $THIS->email->cc($cc); 
    } 
    if (!empty($bcc)) 
    { 
     $THIS->email->cc($bcc); 
    } 
    $THIS->email->subject($subject); 
    $THIS->email->message($body); 

    if (!empty($attachment)) 
    { 
     if (is_array($attachment)) 
     { 
      foreach ($attachment as $val) 
      { 
       $THIS->email->attach($val); 
      } 
     } 
     else 
     { 
      $THIS->email->attach($val); 
     } 
    } 

    if ($THIS->email->send()) 
    { 
     return TRUE; 
    } 
    else{ 
     echo $THIS->email->print_debugger(); 
     exit; 
    } 

Mark es akzeptiert, wenn es funktioniert.

Verwandte Themen