겸손한 개발을 위한 자양분

PHP 에서 mail 함수 정상 동작하는지 확인하는 소스
<?php
 //$mailto="받는주소";
 $mailto="sample@a.com";
 $subject="mail test";
 $content="test";
 $result=mail($mailto, $subject, $content);
 if($result){
  echo "mail success";
  }else  {
  echo "mail fail";
 }
?>

test.php 로 저장하여,
웹페이지에서 로드했을때
mail success 가 찍혀야 정상

만약, 위 소소에서 mail success 가 찍히는데
각종 커스텀 보드에서 메일 발송이 되지 않는다면,
php소스에서 mail 함수의 각 인자들을 확인해본다.

error_log($mailto, 0);  // mailto 변수를 서버의 에러로그에 찍는다.
error_log($subject, 0);

가령,
<?php
 //$mailto="받는주소";
 $mailto="sample@a.com";
 $subject="mail test";
 $content="test";
 $result=mail($mailto, $subject, $content);
 if($result){
  echo "mail success";
  }else  {

  error_log($mailto, 0); 

  echo "mail fail";
 }
?>
일 경우,
Apache 서버를 구동중이라면,
Apache\logs\error.log
파일에 mailto 변수의 내용이 찍힌다.

지금 내가 사용중인 환경은
Apache2.2.8 + SMTP(W2K3 R2) + PHP5.2.5

위와 같이 테스트에서 이상이 없었으나,
제로보드에서는 메일을 보내지 못하는 현상이 발생한다.

따라서,
제로보드의 메일발송 소스를 확인해보니,
받는 사람(Receiptor) 변수에

위의 예제에서는 "sample@a.com" 이지만,
제로보드는 "받는사람 이름 <sample@a.com>"을 설정한다.

Receiptor 변수를 임의로 "sample@a.com"으로 수정하고
정상 작동하는 것을 확인
해당 소스를 수정해주었다.

제로보드\classes\mail\Mail.class.php
function getReceiptor() {
  //if($this->receiptor_name) return sprintf("%s <%s>", '=?utf-8?b?'.base64_encode($this->receiptor_name).'?=', $this->receiptor_email);
  return $this->receiptor_email;
}

수정이후 정상 발송 확인
끝~!

Outlook Express에서 메일 발송이 되지 않는다.

기술 자료 ID : 601904
마지막 검토 : 2003년 7월 28일 월요일
수정 : 1.3
이 문서는 이전에 다음 ID로 출판되었음: KR601904

현상

Exchange 2000을 설치 후 클라이언트에서 Outlook Express을 설정하고 외부로 메일을 보낼 때 다음과 같은 에러가 발생합니다.
"받는 사람 중 한 사람이 서버에서 거부되었으므로 메시지를 보낼 수 없습니다. 
거부된 전자 메일 주소는 'mgkim7@hotmail.com'입니다. 
제 목 'Test', 계정: '157.60.8.33', 서버: '157.60.8.33', 프로토콜: SMTP, 
서버 응답: '550 5.7.1 Unable to relay for mgkim7@hotmail.com', 포트: 25, 
보안(SSL): 아니오, 서버 오류: 550, 오류 번호: 0x800CCC79"
					

위로 가기

원인

SMTP 가상 서버에서 릴레이(Relay)가 거부되었기 때문입니다.

위로 가기

해결 방법

방법 1 : Outlook Express를 실행하는 컴퓨터가 릴레이가 가능하도록 다음의 단계를 실행하여 SMTP 가상서버의 Relay Restrictions에 클라이언트 컴퓨터를 추가합니다.

1. Exchange System Manager를 열고 Administrative Group - First Administrative Group – Servers - COMPUTER_NAME – Protocols - SMTP 아래로 확장합니다.
2. Default SMTP Virtual Server의 등록정보를 엽니다.
3. Access 탭에서 Relay 단추를 클릭합니다.
4. Relay Restrictions 화면에서 클라이언트 컴퓨터를 추가합니다.
방법 2 : SMTP 가상 서버에서 Allow all computers which successfully authenticate to relay, regardless of the list above가 활성화되어 있는 경우에는 다음과 같이 Outlook Express에서 보내는 메일 서버에 로그온 하도록 설정합니다.

1. Outlook Express를 실행하고 도구 메뉴에서 계정을 선택합니다.
2. 메일 계정을 선택하고 등록 정보 단추를 선택합니다.
3. 서버 탭을 선택하고 보내는 메일 서버에서 인증 필요 체크 박스를 선택하고 설정 단추를 누릅니다.
4. 보내는 메일 서버 화면에서 보내는 사람의 계정이 받는 메일 서버의 계정과 같은 경우에는 받는 메일서버와 동일한 설정 사용 라디오 단추를 선택합니다. 계정이 다른 경우에는 로그온 정보에 계정이름과 암호를 입력합니다.

How the IME System Works

MSDN2008. 5. 16. 10:10
How the IME System Works

Glossary

  • Input Method Profiler (IMP): The module on Windows NT 3.5 that keeps track of IMEs installed on the system.
  • Input Method Manager (IMM): The module on Windows that handles communication between IMEs and applications.

The IME module on Windows fits into a larger mechanism for passing user input to applications, and this section briefly describes this overall framework. Unless you are writing an IME package or customizing your IME user interface, you don't need to worry about the details behind the other components.

On Windows NT, the Input Method Profiler (IMP) stores information about each IME, such as whether it is currently active. Control Panel calls the IMP API to add, delete, or activate an individual IME. To get an idea of what kind of information the IMP handles, click the IME icon in the Windows NT 3.5 Control Panel. When the user changes the active IME via Control Panel, the IMP sends a WM_IME_REPORT message to all applications, with wParam set to IR_IMESELECT. More than one IME can be installed on the system, although on Windows NT 3.5 only one can be active at a time.

On Windows 95, multiple IMEs are handled by the multilingual API instead of by an Input Method Profiler. (See Chapter 6 for a description of the multilingual API.) Windows stores information about each IME installed on the system in the system registry (in the H_KEY_CURRENT_USER\Control Panel\Input Method section). The user switches IMEs the same way the user switches Western keyboard layouts—by clicking the input language menu on the taskbar or by entering a shortcut-key combination. The change is reflected on the taskbar indicator:

Switching IMEs generates the same messages as switching other keyboard layouts: WM_INPUTLANGCHANGEREQUEST and WM_INPUTLANGCHANGE. Applications can activate specific IMEs by calling ActivateKeyboardLayout.

The IMM manages communication between IMEs and applications, serving as the go-between. On Windows NT 3.5, the IMM API is called almost exclusively by the system. Applications can call two IMM functions: WINNLSEnableIME, which enables or disables an IME, and WINNLSGetEnableStatus, which returns the enabled or disabled status set by WINNLSEnableIME. On Windows 95, applications can call a number of IMM API functions in order to customize the IME user interface, as described in the section titled "Customized IME Support on Windows 95".

In concept, Input Method Editors are the same as keyboard drivers, but IMEs handle more characters, and Far East systems require some extra code to handle them. On Windows 95, the Input Method Manager is an extension of USER.EXE. Figure 7-17 below illustrates the way in which the IME, the application, and the rest of the system on Windows 95 communicate.

Figure 7-17 Communication between the IME, the application, and the rest of the Windows 95 system.

When the IME program is active, it traps all keyboard events, including the virtual keys listed in Figure 7-18 below. You can see how some of these virtual-key codes correspond to the IME states listed in Figure 7-6 and Figure 7-10. Unless you are writing an IME package or bypassing the IME module to create your own application-specific input mechanism (definitely not recommended!), you don't need to worry about adding code to respond to these virtual keys.

   
Virtual Key Description
VK_DBE_ALPHANUMERIC Changes the mode to alphanumeric
VK_DBE_KATAKANA Changes the mode to katakana
VK_DBE_HIRAGANA Changes the mode to hiragana
VK_DBE_SBCSCHAR Changes the mode to single-byte characters
VK_DBE_DBCSCHAR Changes the mode to double-byte characters
VK_DBE_ROMAN Changes the mode to Roman characters
VK_DBE_NOROMAN Changes the mode to non-Roman characters
VK_DBE_CODEINPUT Changes the mode to code input
VK_DBE_NOCODEINPUT Changes the mode to non-code input
VK_DBE_ENTERIMECONFIGMODE Activates a dialog box for setting up an IME environment
VK_DBE_ENTERWORDREGISTERMODE Activates the word registration dialog box
VK_DBE_FLUSHSTRING Deletes the undetermined string without determining it
VK_HANGEUL Changes the mode to hangul
VK_HANJA Changes the mode to hanja
VK_JUNJA Changes the mode to junja
VK_PROCESSKEY (Windows 95) Tells the application that the IME has processed a virtual key; to retrieve the value of the virtual key, applications can call ImmGetVirtualKey

Figure 7-18 IME virtual keys.

WM_CHAR

MSDN2008. 5. 15. 15:49
WM_CHAR Notification

The WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. The WM_CHAR message contains the character code of the key that was pressed.

Syntax

WM_CHAR

    WPARAM wParam
    LPARAM lParam;
    

Parameters

wParam
Specifies the character code of the key.
lParam
Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table.
0-15
Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.
16-23
Specifies the scan code. The value depends on the OEM.
24
Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
25-28
Reserved; do not use.
29
Specifies the context code. The value is 1 if the ALT key is held down while the key is pressed; otherwise, the value is 0.
30
Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up.
31
Specifies the transition state. The value is 1 if the key is being released, or it is 0 if the key is being pressed.

Return Value

An application should return zero if it processes this message.


Remarks

The WM_CHAR message uses Unicode Transformation Format (UTF)-16.

Because there is not necessarily a one-to-one correspondence between keys pressed and character messages generated, the information in the high-order word of the lParam parameter is generally not useful to applications. The information in the high-order word applies only to the most recent WM_KEYDOWN message that precedes the posting of the WM_CHAR message.

For enhanced 101- and 102-key keyboards, extended keys are the right ALT and the right CTRL keys on the main section of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN and arrow keys in the clusters to the left of the numeric keypad; and the divide (/) and ENTER keys in the numeric keypad. Some other keyboards may support the extended-key bit in the lParam parameter.

Windows XP: The WM_UNICHAR message is the same as WM_CHAR, except it uses UTF-32. It is designed to send or post Unicode characters to ANSI windows, and it can handle Unicode Supplementary Plane characters.

Notification Requirements

Minimum DLL Version None
Header Declared in Winuser.h, include Windows.h
Minimum operating systems Windows 95, Windows NT 3.1

See Also

Keyboard Input Overview, TranslateMessage, WM_KEYDOWN, WM_UNICHAR