Php 如何跟踪从到codeigniter应用程序的电子邮件
我正在用codeigniter编写一个应用程序,这显然已经完成了,但我只想在其中再添加一个插件。我想捕获从outlook帐户到codeigniter应用程序的所有电子邮件 如果我能在我的Codenigger应用程序上发送和接收消息,那就太棒了Php 如何跟踪从到codeigniter应用程序的电子邮件,php,codeigniter,email,outlook,agenda,Php,Codeigniter,Email,Outlook,Agenda,我正在用codeigniter编写一个应用程序,这显然已经完成了,但我只想在其中再添加一个插件。我想捕获从outlook帐户到codeigniter应用程序的所有电子邮件 如果我能在我的Codenigger应用程序上发送和接收消息,那就太棒了 我的第二个问题是如何将我的议程从codeigniter应用程序api到outlook的议程?电子邮件在一些协议上工作,这些协议适用于传入(IMAP)和传出(SMTP)或类似的POP3等 因此,您必须在outlook中配置这些设置以读取邮件和发送邮件。同样,
我的第二个问题是如何将我的议程从codeigniter应用程序api到outlook的议程?电子邮件在一些协议上工作,这些协议适用于传入(IMAP)和传出(SMTP)或类似的POP3等 因此,您必须在outlook中配置这些设置以读取邮件和发送邮件。同样,您可以用PHP阅读邮件,也可以用PHP发送邮件 发送电子邮件: 您可以使用codeigniter核心电子邮件库,它可以很好地用于发送邮件 阅读邮件: 此脚本可以通过提供您提供给outlook的配置来读取您的邮件
<?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@mailprovider.com';
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;
}
}
?>
这是一个阅读邮件的基本脚本,您可以根据需要对其进行增强 电子邮件适用于传入(IMAP)和传出(SMTP)或类似协议,如POP3等 因此,您必须在outlook中配置这些设置以读取邮件和发送邮件。同样,您可以用PHP阅读邮件,也可以用PHP发送邮件 发送电子邮件: 您可以使用codeigniter核心电子邮件库,它可以很好地用于发送邮件 阅读邮件: 此脚本可以通过提供您提供给outlook的配置来读取您的邮件
<?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@mailprovider.com';
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;
}
}
?>
这是一个阅读邮件的基本脚本,您可以根据需要对其进行增强