CI 묻고 답하기

제목 smtp 메일 보내기가 안됩니다.
글쓴이 강일구 작성시각 2015/12/17 21:33:40
댓글 : 2 추천 : 0 스크랩 : 1 조회수 : 30118   RSS
안녕하세요. 신입회원 강일구 입니다.

다름이아니오라 제가 개발에 애로사항이 있어 여러분께 여쭙고자 합니다.

smtp로 메일을 보내는데 잘 되지 않아 문의드립니다.

테스트 버전은 코드이그나이터3.0 이며 2.x도 동일하게 실패합니다.

아래는 소스코드와 각 테스트 별 오류 메시지 입니다.

class 클래스이름 extends CI_Controller {

	
	function smtpTest(){
		$config["protocol"]="smtp";
		
		$config["smtp_host"]="smtp.naver.com"; //smtp.gmail.com
		$config["smtp_user"]="메일아이디@naver.com"; //메일아이디@gmail.com
		$config["smtp_pass"]="비밀번호";
		$config["smtp_port"]=587; //465
		$config["smtp_crypto"]="tls"; //ssl

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

		$this->load->library("email");
		$this->email->initialize($config);
		
		$this->email->from("메일아이디@naver.com");
		$this->email->to("수신자");
		$this->email->subject("jeMok");
		$this->email->message("naeYong");
		$this->email->send();
		
		echo $this->email->print_debugger();
		
	}
}

 

 

테스트 목차

1. smtp.naver.com, 587, tls

2. smtp.naver.com, 587, ssl

3. smtp.naver.com, 465, ssl

4. smtp.gmail.com, 465, tls

5. smtp.gmail.com, 465, ssl

6. smtp.gmail.com, 587, tls

7. smtp.gmail.com, 587, ssl

 

 

1. smtp.naver.com, 587, tls

가. print_debugger() 출력내용

220 smtp.naver.com ESMTP ofuypmkORJSjMu5OY77pBw - nsmtp

hello: 250-smtp.naver.com Pleased to meet you

250-SIZE 20971520

250-8BITMIME

250-PIPELINING

250-STARTTLS

250-AUTH PLAIN LOGIN

250 ENHANCEDSTATUSCODES

starttls: 220 2.0.0 Ready to start TLS ofuypmkORJSjMu5OY77pBw - nsmtp

hello: 250-smtp.naver.com Pleased to meet you

250-SIZE 20971520

250-8BITMIME

250-PIPELINING

250-AUTH PLAIN LOGIN

250 ENHANCEDSTATUSCODES

from: 250 2.1.0 OK ofuypmkORJSjMu5OY77pBw - nsmtp

to: 250 2.1.5 OK ofuypmkORJSjMu5OY77pBw - nsmtp

data: 354 Go ahead ofuypmkORJSjMu5OY77pBw - nsmtp

 

The following SMTP error was encountered:

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

User-Agent: CodeIgniter

Date: Thu, 17 Dec 2015 21:17:19 +0900

From: <메일아이디@naver.com>

Return-Path: <메일아이디@naver.com>

To: 수신자

Subject: =?utf-8?Q?=6A=65=4D=6F=6B?=

Reply-To: "메일아이디@naver.com" <메일아이디@naver.com>

X-Sender: 메일아이디@naver.com

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <5672a7cfd4e58@naver.com>

Mime-Version: 1.0

 

 

Content-Type: text/plain; charset=utf-8

Content-Transfer-Encoding: 8bit

 

naeYong

 

나. 오류 메시지 내용

A PHP Error was encountered

 

Severity: Warning

 

Message: fwrite(): SSL operation failed with code 1. OpenSSL Error messages: error:140D00CF:SSL routines:SSL_write:protocol is shutdown

 

Filename: libraries/Email.php

 

Line Number: 2132

 

Backtrace:

 

//해당 내용 26회 반복 출력

 

 

2. smtp.naver.com, 587, ssl

가. 오류 메시지 내용

A PHP Error was encountered

 

Severity: Warning

 

Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

 

Filename: libraries/Email.php

 

Line Number: 1950

 

Backtrace:

 

File: /웹경로/application/controllers/클래스이름.php

Line: 29

Function: send

 

File: /웹경로/index.php

Line: 292

Function: require_once

 

A PHP Error was encountered

 

Severity: Warning

 

Message: fsockopen(): Failed to enable crypto

 

Filename: libraries/Email.php

 

Line Number: 1950

 

Backtrace:

 

File: /웹경로/application/controllers/클래스이름.php

Line: 29

Function: send

 

File: /웹경로/index.php

Line: 292

Function: require_once

 

A PHP Error was encountered

 

Severity: Warning

 

Message: fsockopen(): unable to connect to ssl://smtp.naver.com:587 (Unknown error)

 

Filename: libraries/Email.php

 

Line Number: 1950

 

Backtrace:

 

File: /웹경로/application/controllers/클래스이름.php

Line: 29

Function: send

 

File: /웹경로/index.php

Line: 292

Function: require_once

 

나. print_debugger() 출력내용

The following SMTP error was encountered: 0

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

User-Agent: CodeIgniter

Date: Thu, 17 Dec 2015 21:25:44 +0900

From: <메일아이디@naver.com>

Return-Path: <메일아이디@naver.com>

To: 수신자

Subject: =?utf-8?Q?=6A=65=4D=6F=6B?=

Reply-To: "메일아이디@naver.com" <메일아이디@naver.com>

X-Sender: 메일아이디@naver.com

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <5672a9c8a0de9@naver.com>

Mime-Version: 1.0

 

 

Content-Type: text/plain; charset=utf-8

Content-Transfer-Encoding: 8bit

 

naeYong

 

 

3. smtp.naver.com, 465, ssl – 1과 같은 순서, 같은 내용으로 출력

 

 

4. smtp.gmail.com, 465, tls

가. 오류 메시지 내용

A PHP Error was encountered

 

Severity: Notice

 

Message: fwrite(): send of 9 bytes failed with errno=32 Broken pipe

 

Filename: libraries/Email.php

 

Line Number: 2132

 

Backtrace:

 

File: /웹경로/application/controllers/클래스이름.php

Line: 29

Function: send

 

File: /웹경로/index.php

Line: 292

Function: require_once

 

//해당 내용 25회 반복

 

나. print_debugger() 출력내용

 

hello: ꠘꠗꠑꠓꠓF

The following SMTP error was encountered: ꠘꠗꠑꠓꠓF

Unable to send data: STARTTLS

starttls:

The following SMTP error was encountered:

The following SMTP error was encountered:

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

User-Agent: CodeIgniter

Date: Thu, 17 Dec 2015 21:35:04 +0900

From: <메일아이디@gmail.com>

Return-Path: <메일아이디@gmail.com>

To: 수신자

Subject: =?utf-8?Q?=6A=65=4D=6F=6B?=

Reply-To: "메일아이디@gmail.com" <메일아이디@gmail.com>

X-Sender: 메일아이디@gmail.com

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <5672abf80c969@gmail.com>

Mime-Version: 1.0

 

 

Content-Type: text/plain; charset=utf-8

Content-Transfer-Encoding: 8bit

 

naeYong

 

다. 오류 메시지 내용

A PHP Error was encountered

 

Severity: Notice

 

Message: fwrite(): send of 5 bytes failed with errno=32 Broken pipe

 

Filename: libraries/Email.php

 

Line Number: 2132

 

Backtrace:

 

// 해당 내용 25회 반복

 

 

5. smtp.gmail.com, 465, ssl

가. print_debugger() 출력내용

220 smtp.gmail.com ESMTP ud10sm15795246pab.27 - gsmtp

hello: 250-smtp.gmail.com at your service, [211.44.250.159]

250-SIZE 35882577

250-8BITMIME

250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH

250-ENHANCEDSTATUSCODES

250-PIPELINING

250-CHUNKING

250 SMTPUTF8

Failed to authenticate password. Error: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/answer/14257 220 smtp.gmail.com ESMTP ud10sm15795246pab.27 - gsmtp

hello: 250-smtp.gmail.com at your service, [211.44.250.159]

250-SIZE 35882577

250-8BITMIME

250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH

250-ENHANCEDSTATUSCODES

250-PIPELINING

250-CHUNKING

250 SMTPUTF8

Failed to authenticate password. Error: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/answer/14257 ud10sm15795246pab.27 - gsmtp

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

User-Agent: CodeIgniter

Date: Thu, 17 Dec 2015 21:42:39 +0900

From: <메일아이디@gmail.com>

Return-Path: <메일아이디@gmail.com>

To: 수신자

Subject: =?utf-8?Q?=6A=65=4D=6F=6B?=

Reply-To: "메일아이디@gmail.com" <메일아이디@gmail.com>

X-Sender: 메일아이디@gmail.com

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <5672adbf5a59f@gmail.com>

Mime-Version: 1.0

 

 

Content-Type: text/plain; charset=utf-8

Content-Transfer-Encoding: 8bit

 

naeYong

 

 

6. smtp.gmail.com, 587, tls

가. print_debugger() 출력내용

220 smtp.gmail.com ESMTP 15sm11414926pfo.43 - gsmtp

hello: 250-smtp.gmail.com at your service, [211.44.250.159]

250-SIZE 35882577

250-8BITMIME

250-STARTTLS

250-ENHANCEDSTATUSCODES

250-PIPELINING

250-CHUNKING

250 SMTPUTF8

starttls: 220 2.0.0 Ready to start TLS

hello: 250-smtp.gmail.com at your service, [211.44.250.159]

250-SIZE 35882577

250-8BITMIME

250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH

250-ENHANCEDSTATUSCODES

250-PIPELINING

250-CHUNKING

250 SMTPUTF8

Failed to authenticate password. Error: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/answer/14257 15sm11414926pfo.43 - gsmtp

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

User-Agent: CodeIgniter

Date: Thu, 17 Dec 2015 21:45:07 +0900

From: <메일아이디@gmail.com>

Return-Path: <메일아이디@gmail.com>

To: 수신자

Subject: =?utf-8?Q?=6A=65=4D=6F=6B?=

Reply-To: "메일아이디@gmail.com" <메일아이디@gmail.com>

X-Sender: 메일아이디@gmail.com

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <5672ae534c10d@gmail.com>

Mime-Version: 1.0

 

 

Content-Type: text/plain; charset=utf-8

Content-Transfer-Encoding: 8bit

 

naeYong

 

 

7. smtp.gmail.com, 587, ssl

가. 오류 메시지 내용

A PHP Error was encountered

 

Severity: Warning

 

Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

 

Filename: libraries/Email.php

 

Line Number: 1950

 

Backtrace:

 

File: /웹경로/application/controllers/클래스이름.php

Line: 29

Function: send

 

File: /웹경로/index.php

Line: 292

Function: require_once

 

A PHP Error was encountered

 

Severity: Warning

 

Message: fsockopen(): Failed to enable crypto

 

Filename: libraries/Email.php

 

Line Number: 1950

 

Backtrace:

 

File: /웹경로/application/controllers/클래스이름.php

Line: 29

Function: send

 

File: /웹경로/index.php

Line: 292

Function: require_once

 

A PHP Error was encountered

 

Severity: Warning

 

Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:587 (Unknown error)

 

Filename: libraries/Email.php

 

Line Number: 1950

 

Backtrace:

 

File: /웹경로/application/controllers/클래스이름.php

Line: 29

Function: send

 

File: /웹경로/index.php

Line: 292

Function: require_once

 

나. print_debugger() 출력내용

The following SMTP error was encountered: 0

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

User-Agent: CodeIgniter

Date: Thu, 17 Dec 2015 21:45:43 +0900

From: <메일아이디@gmail.com>

Return-Path: <메일아이디@gmail.com>

To: 수신자

Subject: =?utf-8?Q?=6A=65=4D=6F=6B?=

Reply-To: "메일아이디@gmail.com" <메일아이디@gmail.com>

X-Sender: 메일아이디@gmail.com

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <5672ae77b87cf@gmail.com>

Mime-Version: 1.0

 

 

Content-Type: text/plain; charset=utf-8

Content-Transfer-Encoding: 8bit

 

naeYong

 

 

네이버, 지메일 각 유형별 7가지 오류메시지 입니다.

사실 더 많은데 우선 이 문제에 대해서만 질문 드리겠습니다.

위의 문제들을 해결하려면 어떻게 해야 하나요?

참고로 5번 항목에 비밀번호가 틀렸다고 나온느 것처럼 보이는데 비밀번호 틀리지 않게 썼습니다.

 

많은 조언과 해결 방안 부탁드립니다. 감사합니다.

 다음글 sqlsrv 드라이버 사용시.. sqlsrv_next_...
 이전글 비밀번호 체크 입니다 제발 살려주세요 7시간째 삽질중입... (2)

댓글

kaido / 2015/12/18 08:38:01 / 추천 0

적혀 있네요.

A PHP Error was encountered

 

Severity: Warning

 

Message: fwrite(): SSL operation failed with code 1

 

 

ssl 포트가 안열리는것 같습니다.

포트 설정 확인해 주세요.

kaido / 2015/12/18 08:46:29 / 추천 0

$config['useragent'] = 'your name';

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

//$config['mailpath'] = '/usr/sbin/sendmail';

$config['smtp_host'] = 'ssl://smtp.googlemail.com';

$config['smtp_user'] = 'your id @gmail.com';

$config['smtp_pass'] = 'your password';

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

$config['wordwrap'] = TRUE;$config['wrapchars'] = 76;

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

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

$config['validate'] = FALSE;

$config['priority'] = 3;

$config['crlf'] = "\r\n";

$config['newline'] = "\r\n";

$config['bcc_batch_mode'] = FALSE;

$config['bcc_batch_size'] = 200;

 

현재 제 메일 설정 입니다. 참고용으로 봐주세요.