本文整理汇总了PHP中Zend_Mail_Protocol_Smtp类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Mail_Protocol_Smtp类的具体用法?PHP Zend_Mail_Protocol_Smtp怎么用?PHP Zend_Mail_Protocol_Smtp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Mail_Protocol_Smtp类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _sendMail
/**
* Send an email via the SMTP connection protocol
*
* The connection via the protocol adapter is made just-in-time to allow a
* developer to add a custom adapter if required before mail is sent.
*
* @return void
* @todo Rename this to sendMail, it's a public method...
*/
public function _sendMail()
{
// If sending multiple messages per session use existing adapter
if (!$this->_connection instanceof Zend_Mail_Protocol_Smtp) {
// Check if authentication is required and determine required class
$connectionClass = 'Zend_Mail_Protocol_Smtp';
if ($this->_auth) {
$connectionClass .= '_Auth_' . ucwords($this->_auth);
}
if (!class_exists($connectionClass)) {
Zend_Loader::loadClass($connectionClass);
}
$this->setConnection(new $connectionClass($this->_host, $this->_port, $this->_config));
$this->_connection->connect();
$this->_connection->helo($this->_name);
} else {
// Reset connection to ensure reliable transaction
$this->_connection->rset();
}
// Set sender email address
$this->_connection->mail($this->_mail->getReturnPath());
// Set recipient forward paths
foreach ($this->_mail->getRecipients() as $recipient) {
$this->_connection->rcpt($recipient);
}
// Issue DATA command to client
$this->_connection->data($this->header . Zend_Mime::LINEEND . $this->body);
}
示例2: sendMassMailingAction
/**
* Sends mass mailing.
* Prepares data and tests the recipients list before sendig emails.
*
* @param int $releaseID The release of the the newsletter to send.
*
* @return array Contains data corresponding to the send result.
*/
public function sendMassMailingAction($releaseID = null)
{
$this->disableView();
if (!$releaseID) {
$releaseID = $_REQUEST['releaseID'];
}
// $releaseID = $this->view->params['releaseID'];
// 1- Get all newsletter to send
$dateTimeNow = date('Y-m-d H:i:s');
$newsletterSelect = new NewsletterReleases();
$select = $newsletterSelect->select()->setIntegrityCheck(false);
$select->from('Newsletter_Releases')->join('Languages', 'L_ID = NR_LanguageID')->join('CategoriesIndex', 'CI_CategoryID = NR_CategoryID')->join('Newsletter_Models_Index', 'NMI_NewsletterModelID = NR_ModelID')->join('Newsletter_Models', 'NM_ID = NMI_NewsletterModelID')->where('CI_LanguageID = NR_LanguageID')->where('NMI_LanguageID = NR_LanguageID')->where('NR_Status <> 1')->where('NR_ID = ?', $releaseID);
$newsletterData = $newsletterSelect->fetchAll($select);
foreach ($newsletterData as $release) {
$listSent = array();
$listDest = array();
$listIds = array();
$mailLog = array();
$date = new Zend_Date($release['NR_Date'], null, Zend_Registry::get('languageSuffix') == 'fr' ? 'fr_CA' : 'en_CA');
$date_string = Cible_FunctionsGeneral::dateToString($date, Cible_FunctionsGeneral::DATE_LONG_NO_DAY, '.');
$date_string_url = Cible_FunctionsGeneral::dateToString($date, Cible_FunctionsGeneral::DATE_SQL, '-');
$releaseLanguage = $release['NR_LanguageID'];
$this->view->assign('languageRelease', $releaseLanguage);
$filteredData = $this->_countFilterMembers($release['NR_CollectionFiltersID'], $releaseLanguage);
$members = $filteredData['members'];
$selection = $filteredData['selection'];
$dateTimeStart = date('Y-m-d H:i:s');
$member_count = 0;
$stats = array('action' => 'set', 'sentTo' => 0, 'targetedTotal' => 0);
if ($release['NR_Status'] == 0 || $release['NR_Status'] == 3) {
//Send to all recipient even if they have already received it
$member_count = count($members);
} elseif ($release['NR_Status'] == 2) {
$member_count = count($members);
$stats['action'] = 'increment';
//Send to recipient who have not already received it
$alreadyMembersRecievedSelect = new NewsletterReleasesMembers();
$select = $alreadyMembersRecievedSelect->select()->where('NRM_ReleaseID = ?', $release['NR_ID']);
$alreadyMembersRecievedData = $alreadyMembersRecievedSelect->fetchAll($select);
$already_received_count = count($alreadyMembersRecievedData);
$membersTmp = array();
for ($i = 0; $i < $member_count; $i++) {
$received = "false";
for ($j = 0; $j < $already_received_count; $j++) {
if ($members[$i]['GP_MemberID'] == $alreadyMembersRecievedData[$j]['NRM_MemberID']) {
$received = "true";
}
}
if ($received == "false") {
array_push($membersTmp, $members[$i]);
}
}
$members = $membersTmp;
$member_count = count($members);
}
$stats['targetedTotal'] = $member_count;
if (!empty($members) && $member_count > 0) {
$newsletterArticlesSelect = new NewsletterArticles();
$select = $newsletterArticlesSelect->select();
$select->where('NA_ReleaseID = ?', $release['NR_ID'])->order('NA_ZoneID')->order('NA_PositionID');
$newsletterArticlesData = $newsletterArticlesSelect->fetchAll($select);
$this->view->articles = $newsletterArticlesData->toArray();
$registry = Zend_Registry::getInstance()->set('format', 'email');
$config = Zend_Registry::get('config')->toArray();
$nbMax = $config['massMailing']['packof'];
$sleep = $config['massMailing']['sleep'];
$server = $config['massMailing']['server'];
$i = 0;
set_time_limit(0);
$emailValidator = new Zend_Validate_EmailAddress();
$sentToCount = 0;
$failedEmailAddress = array();
for ($k = 0; $k < $member_count; $k++) {
try {
if ($i == $nbMax) {
$protocol->quit();
$protocol->disconnect();
sleep($sleep);
$i = 0;
}
if ($i == 0) {
$transport = new Zend_Mail_Transport_Smtp();
$protocol = new Zend_Mail_Protocol_Smtp($server);
$protocol->connect();
$protocol->helo($server);
$transport->setConnection($protocol);
}
$protocol->rset();
if ($emailValidator->isValid($members[$k]['GP_Email'])) {
$date = new Zend_Date($release['NR_Date'], null, Zend_Registry::get('languageSuffix') == 'fr' ? 'fr_CA' : 'en_CA');
$date_string = Cible_FunctionsGeneral::dateToString($date, Cible_FunctionsGeneral::DATE_LONG_NO_DAY, '.');
$date_string_url = Cible_FunctionsGeneral::dateToString($date, Cible_FunctionsGeneral::DATE_SQL, '-');
//.........这里部分代码省略.........
示例3: _connectAndEhlo
/**
* Performs the initial EHLO dialog
*/
protected function _connectAndEhlo()
{
$this->_protocol->responseBuffer = array('220 example.com ESMTP welcome', '250 Hello 127.0.0.1, go ahead');
$this->_protocol->connect();
$this->_protocol->helo();
return $this->_protocol->dialog;
}
示例4: auth
/**
* Perform PLAIN authentication with supplied credentials
*
* @return void
*/
public function auth()
{
// Ensure AUTH has not already been initiated.
parent::auth();
$this->_send('AUTH PLAIN');
$this->_expect(334);
$this->_send(base64_encode(chr(0) . $this->_username . chr(0) . $this->_password));
$this->_expect(235);
$this->_auth = true;
}
示例5: auth
/**
* @todo Perform CRAM-MD5 authentication with supplied credentials
*
* @return void
*/
public function auth()
{
// Ensure AUTH has not already been initiated.
parent::auth();
$this->_send('AUTH CRAM-MD5');
$challenge = $this->_expect(334);
$challenge = base64_decode($challenge);
$digest = $this->_hmacMd5($this->_password, $challenge);
$this->_send(base64_encode($this->_username . ' ' . $digest));
$this->_expect(235);
$this->_auth = true;
}