Example #1
0
 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;
 }
Example #2
0
 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;
 }
Example #3
0
 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.');
         }
     }
 }
Example #4
0
 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.');
         }
     }
 }
Example #5
0
 /**
  * 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);
     }
 }
 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;
 }
Example #7
0
 public function testConnection()
 {
     $mail = new PHPMailer(true);
     $mail->IsSMTP();
     $mail->IsHTML(true);
     $mail->CharSet = 'UTF-8';
     $mail->SMTPSecure = "tls";
     $mail->SMTPAuth = true;
     $mail->Username = $this->smtp_username;
     $mail->Password = $this->smtp_password;
     $mail->Host = $this->smtp_host;
     //$mail->SMTPDebug = 2;
     try {
         $mail->SmtpConnect();
     } catch (phpmailerException $e) {
         return false;
     }
     return true;
 }
 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;
 }
Example #9
0
$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>