当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPMailer::SmtpConnect方法代码示例

本文整理汇总了PHP中PHPMailer::SmtpConnect方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::SmtpConnect方法的具体用法?PHP PHPMailer::SmtpConnect怎么用?PHP PHPMailer::SmtpConnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPMailer的用法示例。


在下文中一共展示了PHPMailer::SmtpConnect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SmtpConnect

 public function SmtpConnect($options = array())
 {
     if (!$this->smtp instanceof SMTPProxy) {
         $this->smtp = new SMTPProxy();
     }
     $result = parent::SmtpConnect($options);
     if ($result === false) {
         throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
     }
     return $result;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:11,代码来源:PHPMailerProxy.php

示例2: SmtpConnect

 function SmtpConnect()
 {
     $connection = parent::SmtpConnect();
     if (!$connection) {
         global $app_strings;
         if (isset($this->oe) && $this->oe->type == "system") {
             $this->SetError($app_strings['LBL_EMAIL_INVALID_SYSTEM_OUTBOUND']);
         } else {
             $this->SetError($app_strings['LBL_EMAIL_INVALID_PERSONAL_OUTBOUND']);
         }
         // else
     }
     return $connection;
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:14,代码来源:SugarPHPMailer.php

示例3: mail_test

 private function mail_test()
 {
     if ($this->empresa->can_send_mail()) {
         $mail = new PHPMailer();
         $mail->IsSMTP();
         $mail->SMTPAuth = TRUE;
         $mail->SMTPSecure = $this->mail['mail_enc'];
         $mail->Host = $this->mail['mail_host'];
         $mail->Port = intval($this->mail['mail_port']);
         $mail->Username = $this->empresa->email;
         if ($this->mail['mail_user'] != '') {
             $mail->Username = $this->mail['mail_user'];
         }
         $mail->Password = $this->empresa->email_password;
         $mail->From = $this->empresa->email;
         $mail->FromName = $this->user->nick;
         $mail->CharSet = 'UTF-8';
         $mail->Subject = 'TEST';
         $mail->AltBody = 'TEST';
         $mail->WordWrap = 50;
         $mail->MsgHTML('TEST');
         $mail->IsHTML(TRUE);
         if (!$mail->SmtpConnect()) {
             $this->new_error_msg('No se ha podido conectar por email.');
         }
     }
 }
开发者ID:ramikat,项目名称:ERPSISFS,代码行数:27,代码来源:admin_empresa.php

示例4: mail_test

 private function mail_test()
 {
     if ($this->empresa->can_send_mail()) {
         /// Es imprescindible OpenSSL para enviar emails con los principales proveedores
         if (extension_loaded('openssl')) {
             $mail = new PHPMailer();
             $mail->Timeout = 3;
             $mail->IsSMTP();
             $mail->SMTPAuth = TRUE;
             $mail->SMTPSecure = $this->mail['mail_enc'];
             $mail->Host = $this->mail['mail_host'];
             $mail->Port = intval($this->mail['mail_port']);
             $mail->Username = $this->empresa->email;
             if ($this->mail['mail_user'] != '') {
                 $mail->Username = $this->mail['mail_user'];
             }
             $mail->Password = $this->empresa->email_password;
             $mail->From = $this->empresa->email;
             $mail->FromName = $this->user->nick;
             $mail->CharSet = 'UTF-8';
             $mail->Subject = 'TEST';
             $mail->AltBody = 'TEST';
             $mail->WordWrap = 50;
             $mail->MsgHTML('TEST');
             $mail->IsHTML(TRUE);
             $SMTPOptions = array();
             if ($this->mail['mail_low_security']) {
                 $SMTPOptions = array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true));
             }
             if (!$mail->SmtpConnect($SMTPOptions)) {
                 $this->new_error_msg('No se ha podido conectar por email. ¿La contraseña es correcta?');
                 if ($mail->Host == 'smtp.gmail.com') {
                     $this->new_error_msg('Aunque la contraseña de gmail sea correcta, en ciertas ' . 'situaciones los servidores de gmail bloquean la conexión. ' . 'Para superar esta situación debes crear y usar una ' . '<a href="https://support.google.com/accounts/answer/185833?hl=es" ' . 'target="_blank">contraseña de aplicación</a>');
                 } else {
                     $this->new_error_msg("¿<a href='https://www.facturascripts.com/comm3/index.php?page=community_item&id=74'" . " target='_blank'>Necesitas ayuda</a>?");
                 }
             }
         } else {
             $this->new_error_msg('No se encuentra la extensión OpenSSL,' . ' imprescindible para enviar emails.');
         }
     }
 }
开发者ID:desalort,项目名称:FSAutoventas,代码行数:42,代码来源:admin_empresa.php

示例5: connectToHost

 /**
  * Connects to the SMTP server specified in the PHPMailer configurations. This allows us to establish the connection
  * to the SMTP server and catch any errors associated with the connection instead of letting PHPMailer establish
  * the connection at send time, which would result in losing the context of the failure.
  *
  * @access protected
  * @param PHPMailer $mailer
  * @throws MailerException
  */
 protected function connectToHost(PHPMailer &$mailer)
 {
     try {
         // have PHPMailer attempt to connect to the SMTP server
         $mailer->SmtpConnect();
     } catch (Exception $e) {
         //TODO: need to tell the class what error messages to use, so the following is for reference only
         //            global $app_strings;
         //            if(isset($this->oe) && $this->oe->type == "system") {
         //                $this->SetError($app_strings['LBL_EMAIL_INVALID_SYSTEM_OUTBOUND']);
         //            } else {
         //                $this->SetError($app_strings['LBL_EMAIL_INVALID_PERSONAL_OUTBOUND']);
         //            }
         throw new MailerException("Failed to connect to outbound SMTP Mail Server", MailerException::FailedToConnectToRemoteServer);
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:25,代码来源:SmtpMailer.php

示例6: testUserCredentials

 public function testUserCredentials($email, $password, $server, $port, $security)
 {
     require_once realpath(Yii::app()->basePath . '/components/phpMailer/PHPMailerAutoload.php');
     $phpMail = new PHPMailer(true);
     $phpMail->isSMTP();
     $phpMail->SMTPAuth = true;
     $phpMail->Username = $email;
     $phpMail->Password = $password;
     $phpMail->Host = $server;
     $phpMail->Port = $port;
     $phpMail->SMTPSecure = $security;
     try {
         $validCredentials = $phpMail->SmtpConnect();
     } catch (phpmailerException $error) {
         $validCredentials = false;
     }
     return $validCredentials;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:18,代码来源:EmailDeliveryBehavior.php

示例7: sendEmail

 public function sendEmail($to_array, $subject, $credentials)
 {
     if ($credentials["server"] == NULL) {
         throw new Exception("IMSEmail->sendEmail: SMTP Host Name Missing", 1);
     }
     if ($credentials["user"] == NULL) {
         throw new Exception("IMSEmail->sendEmail: SMTP User Name Missing", 1);
     }
     if ($credentials["password"] == NULL) {
         throw new Exception("IMSEmail->sendEmail: SMTP Password Missing", 1);
     }
     if ($credentials["from_email"] == NULL) {
         throw new Exception("IMSEmail->sendEmail: SMTP From Email Missing", 1);
     }
     if ($credentials["from_name"] == NULL) {
         throw new Exception("IMSEmail->sendEmail: SMTP From Name Missing", 1);
     }
     $mail = new PHPMailer(true);
     //Throw exceptions on error
     $mail->SMTPDebug = 0;
     $mail->isSMTP();
     $mail->Host = $credentials["server"];
     $mail->SMTPAuth = true;
     $mail->Username = $credentials["user"];
     $mail->Password = $credentials["password"];
     $mail->SMTPSecure = "tls";
     $mail->Port = 587;
     $mail->From = $credentials["from_email"];
     $mail->FromName = $credentials["from_name"];
     $footers = "</table>\n</body>\n</head>\n</html>";
     foreach ($to_array as $to) {
         $mail->addAddress($to);
     }
     $mail->isHTML(true);
     $mail->Subject = $subject;
     $emailmessage = fopen("email/IMSEmail.html", "r") or die("IMSEmail: unable to open file in function sendEmail().");
     $mail->Body = fread($emailmessage, filesize("email/IMSEmail.html"));
     fclose($emailmessage);
     $mail->Body .= $footers;
     $mail->AltBody = "If you can't read this email, please use the Shopping List page on the IMS page.";
     try {
         $mail->SmtpConnect();
     } catch (Exception $smtpError) {
         return "Email server credentials are invalid.  Error: {$smtpError}";
     }
     if (!$mail->send()) {
         return "Mailer Error: " . $mail->ErrorInfo;
     } else {
         unlink($this->email_file_loc);
         return "Email sent";
     }
     return;
 }
开发者ID:AngryShrimp,项目名称:CME495_Design_IMS,代码行数:53,代码来源:IMSEmail.php

示例8: catch

$mail->IsSMTP();
// set mailer to use SMTP
$mail->Host = $smtp_host;
// specify SMTP mail server
$mail->Port = $smtp_port;
// specify SMTP Port
$mail->SMTPAuth = $smtp_auth;
// turn on SMTP authentication
$mail->Username = $smtp_user;
//Full SMTP username
$mail->Password = $smtp_pass;
//SMTP password
//if($smtp_secure )
$mail->SMTPSecure = $smtp_secure;
try {
    $mail->SmtpConnect();
    echo "SMTP connected successfully.";
} catch (Exception $e) {
    echo "SMTP not connected. Please verify the details.";
}
$mail->SmtpClose();
/* if($mail->SmtpConnect())
			 	echo "SMTP connected successfully";
			else
				echo "SMTP not connected please verify your configuration";*/
?>
</li>
        <li><?php 
echo "BMH mail username - {$bmh_mailbox_username}";
?>
</li>
开发者ID:Maxlander,项目名称:shixi,代码行数:31,代码来源:smtp_code.php


注:本文中的PHPMailer::SmtpConnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。