本文整理汇总了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;
}
示例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;
}
示例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.');
}
}
}
示例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.');
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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>