공유 호스팅 계획을 사용하고 있습니다. 나는 최고 수준을 시도했지만이 문제를 해결할 수 없습니다. 여기 내 코드입니다. 내가 먼저 Gmail과 함께 노력했지만 그때 내가 어딘가 내 공유 호스팅 계획의 IP는 구글에 의해 블랙리스트에 다음 myap smtp 다음 imap 서버, localhost에서 잘 작동 동일한 결과를 피곤하지만 다시 동일한 내가지고 오류.CodeIgniter 메일이 서버에서 작동하지 않지만 로컬 호스트가 작동합니다.
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Contact extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function __construct()
{
parent::__construct();
$this->load->helper(array('form','url'));
$this->load->library(array('session', 'form_validation', 'email'));
}
public function index()
{
$this->load->helper('security');
//set validation rules
$this->form_validation->set_rules('name', 'Name', 'trim|required|xss_clean|callback_alpha_space_only');
$this->form_validation->set_rules('email', 'Emaid ID', 'trim|required|valid_email');
$this->form_validation->set_rules('subject', 'Subject', 'trim|required|xss_clean');
$this->form_validation->set_rules('message', 'Message', 'trim|required|xss_clean');
//run validation on form input
if ($this->form_validation->run() == FALSE)
{
//validation fails
$this->load->view('head');
$this->load->view('map');
$this->load->view('footer_map');
}
else
{
//get the form data
$name = $this->input->post('name');
$from_email = $this->input->post('email');
$subject = $this->input->post('subject');
$message = $this->input->post('message');
//set to_email id to which you want to receive mails
$to_email = '[email protected]';
//configure email settings
$config['protocol'] = 'imap';
$config['smtp_host'] = 'imap.example.com';
$config['smtp_port'] = '587';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'example';
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n"; //use double quotes
// $this->load->library('email', $config);
$this->email->initialize($config);
//send mail
$this->email->from($from_email, $name);
$this->email->to($to_email);
$this->email->reply_to($from_email, $name);
$this->email->subject($subject);
$this->email->message($message);
if ($this->email->send())
{
// mail sent
$this->session->set_flashdata('msg','<div class="alert alert-success text-center">Your mail has been sent successfully!</div>');
redirect('contact/index');
}
else
{
//error
echo $this->email->print_debugger();
$this->session->set_flashdata('msg','<div class="alert alert-danger text-center">There is error in sending mail! Please try again later</div>');
redirect('contact/index');
}
}
}
public function alpha_space_only($str)
{
if (!preg_match("/^[a-zA-Z ]+$/",$str))
{
$this->form_validation->set_message('alpha_space_only', 'The %s field must contain only alphabets and space');
return FALSE;
}
else
{
return TRUE;
}
}
}
내가 나에게이 출력 너희들을
There is error in sending mail! Please try again later.
도움말을 얻고, 당신이 보이는 게시 된 코드의 라인 73에 피곤
보낸 사람 주소가 해당 도메인의 주소가 아니라면 공유 시스템의 일부 메일 서버는 전자 메일을 보내지 않습니다. 따라서 웹 사이트가 example.com 인 경우 From은 [email protected]이어야합니다. 설정을 시도하고 발신자의 이메일 주소를 답장으로 설정하십시오. – aynber