메일 송수신 실패시 리턴 메일을 받도록 Return-Path 지정하기

댓글

2 comments posted
위 리턴 패스를

위 리턴 패스를 적용한 발송 소스 예제입니다.
발신자(송신자)의 주소가 Hosting 회사의 주소 대신에
소스에 지정한 메일 주소로 바뀝니다.


$MAIL_ADDR_FROM = "reply-to-sample@bulabula-test.com";

// Build the default headers
$headers = array(
    'MIME-Version'      => '1.0',
    'Content-Type'       => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
    'Content-Transfer-Encoding' => '8Bit',
    'Return-Path' => $MAIL_ADDR_FROM,
    'Reply-To' => $MAIL_ADDR_FROM,
    'X-Mailer'   => 'Drupal'
);

// $body : Mail Body.
$message = array(
    // 'id'   => 'mail_notice',
    'from'     => $MAIL_ADDR_FROM,
    // 'language' => user_preferred_language($user_info),
    'body'     =>  $body,
    'headers' => $headers,
);

// $to : Mail Address for Recipient.
$message = array_merge($to, $message);

drupal_mail_send( $message );

Posted by palpal on 화, 2010-06-29 15:05
최근에 메일관련 모듈인 sendmail모듈 대신

최근에
메일관련 모듈인 sendmail모듈 대신 postfix 모듈을 사용하는 서버에
사이트를 이관하는 작업이 있었는데 위의 코드를 사용하면
메일의 'From'부분에 "Apache"라고 표시되는 에러현상이 있었습니다.
(메일 송수신에는 문제 없음)
확인해본 결과
헤더부분에 'From'부분이 포함되어 있지않아서
서버의 디폴트 값이 출력되었었습니다.
아래에 에러수정한 소스 남깁니다.

$MAIL_ADDR_FROM = "reply-to-sample@bulabula-test.com";

$headers = array(
'MIME-Version' => '1.0',
'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
'Content-Transfer-Encoding' => '8Bit',
'Return-Path' => $MAIL_ADDR_FROM,
'Reply-To' => $MAIL_ADDR_FROM,
'X-Mailer' => 'Drupal',
'from' => $MAIL_ADDR_FROM,
);

// $body : Mail Body.
$message = array(
'body' => $body,
'headers' => $headers,
);

// $to : Mail Address for Recipient.
$message = array_merge($to, $message);

drupal_mail_send( $message );

Posted by taisei516 on 금, 2011-05-27 18:13