이메일 수신 (IMAP)에 대한 몇 가지 프로토콜에 및 나가는 (SMTP) 또는 그래서 당신은 당신의 메일을 읽고 메일을 보낼 전망에서 이러한 설정을 구성해야합니다 등
POP3와 같은 유사한 작동합니다. 마찬가지로 PHP로 메일을 읽고 php를 사용하여 메일을 보낼 수 있습니다.
전자 메일 보내기 :
당신은 나가는 잘 작동 코어 이메일 라이브러리를 CodeIgniter를 사용할 수 있습니다. sending emails codeigniter
읽기 우편물 :
이 스크립트는 전망에 제공하는 구성을 제공하여 메일을 읽을 수 있습니다.
<?php
class Email_reader {
// imap server connection
public $conn;
// inbox storage and inbox message count
private $inbox;
private $msg_cnt;
// email login credentials
private $server = 'YOUR_MAIL_SERVER';
private $user = '[email protected]';
private $pass = 'yourpassword';
private $port = 143; // change according to server settings
// connect to the server and get the inbox emails
function __construct() {
$this->connect();
$this->inbox();
}
// close the server connection
function close() {
$this->inbox = array();
$this->msg_cnt = 0;
imap_close($this->conn);
}
// open the server connection
// the imap_open function parameters will need to be changed for the particular server
// these are laid out to connect to a Dreamhost IMAP server
function connect() {
$this->conn = imap_open('{'.$this->server.'/notls}', $this->user, $this->pass);
}
// move the message to a new folder
function move($msg_index, $folder='INBOX.Processed') {
// move on server
imap_mail_move($this->conn, $msg_index, $folder);
imap_expunge($this->conn);
// re-read the inbox
$this->inbox();
}
// get a specific message (1 = first email, 2 = second email, etc.)
function get($msg_index=NULL) {
if (count($this->inbox) <= 0) {
return array();
}
elseif (! is_null($msg_index) && isset($this->inbox[$msg_index]))
{
return $this->inbox[$msg_index];
}
return $this->inbox[0];
}
// read the inbox
function inbox() {
$this->msg_cnt = imap_num_msg($this->conn);
$in = array();
for($i = 1; $i <= $this->msg_cnt; $i++) {
$in[] = array(
'index' => $i,
'header' => imap_headerinfo($this->conn, $i),
'body' => imap_body($this->conn, $i),
'structure' => imap_fetchstructure($this->conn, $i)
);
}
$this->inbox = $in;
}
}
?>
메일을 읽는 기본 스크립트로, 요구 사항에 따라 향상시킬 수 있습니다.
출처
2017-09-29 06:10:26
BSB