2013-01-06 3 views
0

내 코드서명의 Gmail

$headers = 'MIME-Version: 1.0' . PHP_EOL; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL; 
$headers .= 'From: Me <[email protected]>' . PHP_EOL; 
imap_mail('[email protected]','test',"$output","$headers"); 

메일에 서명 할 수있는 방법이 있습니까? 나는 이메일을 보내는 테스트 위의 코드를 사용할 때, 나는 이메일을 수신하지만 오류

This message may not have been sent by: [email protected] Learn more Report phishing 
을 얻고있다

according to gmail 그들은 내가 메일을 보내 Gmail이 IMAP을 사용하고

인증하기 위해 헤더에 서명 된 데이터를 첨부 할

$inbox = imap_open($hostname,$username,$password) 
      or die('Cannot connect to Gmail: ' . imap_last_error()); 

php imap을 사용하여 이메일을 인증하는 방법이 있습니까?

답변

1

Gmail 사용자로 메일을 보내려면 Gmail의 SMTP를 사용하는 것이 좋습니다. IMAP은 주로받은 편지함에서 메일을받는 데 사용됩니다.

다음은 Gmail의 SMTP에서 메일을 보내는 방법입니다. 먼저

  • 배 메일 패키지가 설치되어 있는지 확인

    .

    • 일반적으로 특히 PHP 4 이상에서는 이미 이 완료되었습니다. 한번 시도해보십시오. (Mail.php)
다음

SMTP 인증을 사용하여 PHP에서 메일을 보내기

- 예 SMTP 인증 및 SSL 암호화를 사용하여 PHP에서 메일을 보내기

<?php 
require_once "Mail.php"; 

$from = "Sender <[email protected]>"; 
$to = "Recipient <[email protected]>"; 
$subject = "Hi!"; 
$body = "Hi,\n\nHow are you?"; 

$host = "smtp.gmail.com"; 
$username = "[email protected]"; 
$password = "Gmail Password"; 

$headers = array ('From' => $from, 
    'To' => $to, 
    'Subject' => $subject); 
$smtp = Mail::factory('smtp', 
    array ('host' => $host, 
    'auth' => true, 
    'username' => $username, 
    'password' => $password)); 

$mail = $smtp->send($to, $headers, $body); 

if (PEAR::isError($mail)) { 
    echo("<p>" . $mail->getMessage() . "</p>"); 
    } else { 
    echo("<p>Message successfully sent!</p>"); 
    } 
?> 

- 예

<?php 
require_once "Mail.php"; 

$from = "Sender <[email protected]>"; 
$to = "Recipient <[email protected]>"; 
$subject = "Hi!"; 
$body = "Hi,\n\nHow are you?"; 

$host = "ssl://smtp.gmail.com"; 
$port = "465"; 
$username = "[email protected]"; 
$password = "Gmail Password"; 

$headers = array ('From' => $from, 
    'To' => $to, 
    'Subject' => $subject); 
$smtp = Mail::factory('smtp', 
    array ('host' => $host, 
    'port' => $port, 
    'auth' => true, 
    'username' => $username, 
    'password' => $password)); 

$mail = $smtp->send($to, $headers, $body); 

if (PEAR::isError($mail)) { 
    echo("<p>" . $mail->getMessage() . "</p>"); 
    } else { 
    echo("<p>Message successfully sent!</p>"); 
    } 
?> 

소스 about.com

+1

그냥 구글의 SMTP 서비스 관련 제안 요청 (RFP)에 부합하지 않는 방식으로 헤더을 조작하는 참고 : http://lee-phillips.org/gmailRewriting/ –

관련 문제