개발 Q&A

제목 코드이그나이터를 이용한 이메일 발송 관련해서 질문있습니다.
카테고리 PHP
글쓴이 어쩌다보니 개발자 작성시각 2018/09/07 10:29:38
댓글 : 4 추천 : 0 스크랩 : 0 조회수 : 9755   RSS

안녕하십니까?

 

//메일전송
$this->load->model('user_model');
$users = $this->user_model->gets();

$this->load->library('email');
$this->email->initialize(array('mailtype'=>'htiml'));
foreach ($users as $user)
{
    var_dump($user);
    //메일 기능 구현
    $this->email->from('bluemun0501@gmail.com', '최고관리자');
    $this->email->to($user->email);
    $this->email->subject('이메일 테스트 중입니다.');
    $this->email->message('<a href="'.site_url('/topic/get/'.$topic_id).'">'.$this->input->post('title').'</a>');
    $this->email->send();
}

이렇게 코드를 테스트하고있는데.... 메일 발송에 에러가 생겨서 질문드립니다.

제가 사용하는 컴퓨터 자체에서 SMTP설정이 아니라 메일건이나 그러한 것을 이용한 메일 전송방식을 어떻게 사용하는지

잘 모르겠습니다. 답변해주시면 감사하겠습니다.

 다음글 ci 설정중에 궁금한게 있습니다. (6)
 이전글 이런 복잡한 질의문을 액티브쿼리 사용하는 방법이 있나요 (1)

댓글

어쩌다보니 개발자 / 2018/09/07 10:59:14 / 추천 0

추가적으로 이렇게 했는데 문제가 있을까요??

 

$this->load->library('email');
$this->email->initialize(array('mailtype'=>'htiml'));

//메일 설정
$config['charset']   = "euc-kr";
$config['protocol']  = "smtp";
$config['smtp_host'] = "ssl://smtp.googlemail.com";
$config['smtp_port'] = 465;
$config['smtp_user'] = "bluemun0501@gmail.com";
$config['smtp_pass'] = "";
$config['smtp_timeout'] = 10;


foreach ($users as $user)
{
    var_dump($user);
    //메일 기능 구현
    $this->email->set_newline("\r\n");
    $this->email->from('bluemun0501@gmail.com', '최고관리자');
    $this->email->to($user->email);
    $this->email->subject('이메일 테스트 중입니다.');
    $this->email->message('<a href="'.site_url('/topic/get/'.$topic_id).'">'.$this->input->post('title').'</a>');
    $this->email->send();
}

 이러한 오류가 발생하고 있습니다.

 

A PHP Error was encountered

Severity: Warning

Message: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

Filename: libraries/Email.php

Line Number: 1902

Backtrace:

File: F:\xampp\htdocs\mrj\application\controllers\topic.php
Line: 79
Function: send

File: F:\xampp\htdocs\mrj\index.php
Line: 315
Function: require_once

 

저는 xampp를 이용하고 3.1.9버전의 CI를 사용중입니다.

빛그림 / 2018/09/07 11:06:50 / 추천 0

$this->load->library('email');

$config['charset']   = "euc-kr";
$config['protocol']  = "smtp";
$config['smtp_host'] = "ssl://smtp.googlemail.com";
$config['smtp_port'] = 465;
$config['smtp_user'] = "bluemun0501@gmail.com";
$config['smtp_pass'] = "";
$config['smtp_timeout'] = 10;


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

이렇게 해보시겠어요? 환경설정이 초기화 위에 있어야 할듯 한데...

어쩌다보니 개발자 / 2018/09/07 11:11:08 / 추천 0

우와 감사합니다!

메일 발송이 됐습니다.

gmail은 보안 설정으로 인해 귀찮기는 하네요 ㅎㅎ

빛그림 / 2018/09/07 11:14:22 / 추천 0

윈도우 컴퓨터에서 개발을 하시는 경우라면 IIS를 이용해서 메일을 발송하실수도 있고요. 

APM패키지에서 (패키지 배포자에 의해) 추가된 모듈을 이용해서 발송을 해주도록 하기도 합니다.(포함 안된 APM패키지도 있고요.)

리눅스 서버들은 sendmail을 설치해서 그걸 이용하기도 하고요.