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


PHP Swift_MailTransport::newInstance方法代码示例

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


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

示例1: getTransport

 public function getTransport()
 {
     // Get Joomla mailer
     $config = JFactory::getConfig();
     $jmailer = $config->get('mailer');
     switch ($jmailer) {
         case 'sendmail':
             $this->transport = Swift_SendmailTransport::newInstance($config->get('sendmail') . ' -bs');
             break;
         case 'smtp':
             $this->transport = Swift_SmtpTransport::newInstance($config->get('smtphost'), $config->get('smtpport'));
             if ($config->get('smtpauth') == 1) {
                 $smtpUser = $config->get('smtpuser');
                 $smtpPass = $config->get('smtppass');
                 if (!empty($smtpUser) && !empty($smtpPass)) {
                     $this->transport->setUsername($smtpUser)->setPassword($smtpPass);
                 }
                 $smtpEncryption = $config->get('smtpsecure');
                 if (!empty($smtpEncryption)) {
                     $this->transport->setEncryption($smtpEncryption);
                 }
             }
             break;
         default:
         case 'mail':
             $this->transport = Swift_MailTransport::newInstance();
             break;
     }
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:29,代码来源:mail.php

示例2: __construct

 function __construct()
 {
     // include swift mailer
     require ENGINE_PATH . 'swiftmailer/classes/Swift.php';
     Swift::init();
     Swift::registerAutoload();
     //Yii::import('system.vendors.swiftMailer.classes.Swift', true);
     //Yii::registerAutoloader(array('Swift','autoload'));
     require_once ENGINE_PATH . 'swiftmailer/swift_init.php';
     //Yii::import('system.vendors.swiftMailer.swift_init', true);
     switch ($this->params['transportType']) {
         case 'smtp':
             $transport = Swift_SmtpTransport::newInstance($this->params['smtpServer'], $this->params['smtpPort'], $this->params['smtpSequre'])->setUsername($this->params['smtpUsername'])->setPassword($this->params['smtpPassword']);
             break;
         case 'sendmail':
             $transport = Swift_SendmailTransport::newInstance($this->params['sendmailCommand']);
             break;
         default:
         case 'mail':
             $transport = Swift_MailTransport::newInstance();
             break;
     }
     $this->toEmail = 'noreplay@' . $_SERVER['HTTP_HOST'];
     $this->fromEmail = 'noreplay@' . $_SERVER['HTTP_HOST'];
     $this->path = "http://" . $_SERVER['HTTP_HOST'] . "/submit/mailtpl/";
     $this->mailer = Swift_Mailer::newInstance($transport);
     $this->mes = Swift_Message::newInstance();
 }
开发者ID:rjon76,项目名称:netspotapp,代码行数:28,代码来源:classEmailReporter.php

示例3: connect

 /**
  * Creates a SwiftMailer instance.
  *
  * @param   string  DSN connection string
  * @return  object  Swift object
  */
 public static function connect($config = NULL)
 {
     // Load default configuration
     $config === NULL and $config = Kohana::$config->load('email');
     switch ($config['driver']) {
         case 'smtp':
             // Set port
             $port = empty($config['options']['port']) ? 25 : (int) $config['options']['port'];
             // Create SMTP Transport
             $transport = Swift_SmtpTransport::newInstance($config['options']['hostname'], $port);
             if (!empty($config['options']['encryption'])) {
                 // Set encryption
                 $transport->setEncryption($config['options']['encryption']);
             }
             // Do authentication, if part of the DSN
             empty($config['options']['username']) or $transport->setUsername($config['options']['username']);
             empty($config['options']['password']) or $transport->setPassword($config['options']['password']);
             // Set the timeout to 5 seconds
             $transport->setTimeout(empty($config['options']['timeout']) ? 5 : (int) $config['options']['timeout']);
             break;
         case 'sendmail':
             // Create a sendmail connection
             $transport = Swift_SendmailTransport::newInstance(empty($config['options']) ? "/usr/sbin/sendmail -bs" : $config['options']);
             break;
         default:
             // Use the native connection
             $transport = Swift_MailTransport::newInstance();
             break;
     }
     // Create the SwiftMailer instance
     return self::$_mail = Swift_Mailer::newInstance($transport);
 }
开发者ID:rrsc,项目名称:beansbooks,代码行数:38,代码来源:core.php

示例4: send_email

function send_email($info)
{
    //format each email
    $body = format_email($info, 'html');
    $body_plain_txt = format_email($info, 'txt');
    //setup the mailer
    $transport = Swift_MailTransport::newInstance();
    $mailer = Swift_Mailer::newInstance($transport);
    $message = Swift_Message::newInstance();
    $message->setSubject('Welcome to Geo Home For you');
    $message->setFrom(array('noreply@geomail.com' => 'Site Name'));
    $message->setTo(array($info['email'] => $info['username']));
    $message->setBody($body_plain_txt);
    $message->addPart($body, 'text/html');
    echo "WHAT";
    echo $message;
    //$to = "tepnimitl@gmail.com";
    //$sub = "Te_subject_of_your_email";
    //$mess = "Dear User, \r\n\r\n";
    //$mess .= "This is your message \r\n";
    //$headers = "From: noreply@.com \r\n";
    //$test = mail($to,$subj,$mess,$headers);
    //if (test){echo "TRUE";}else{echo "FALSE";}
    $result = $mailer->send($message);
    return $result;
}
开发者ID:Tepnimit,项目名称:Geo-Home-Systems,代码行数:26,代码来源:functions.php

示例5: assignResetCredentialCode

 public function assignResetCredentialCode($emailAddress)
 {
     $emailAddressRepository = $this->entityManager->getRepository(EmailEntity::class);
     /** @var EmailEntity $emailAddress */
     $emailAddress = $emailAddressRepository->findOneBy(['address' => $emailAddress]);
     if (!$emailAddress || !$emailAddress->isVerified()) {
         return;
     }
     mail('walter.tamboer@live.com', 'Subject', 'data');
     exit('done');
     $validChars = implode('', array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9')));
     $emailAddress->getAccount()->setResetCredentialCode(Rand::getString(32, $validChars));
     $this->passwordChanger->flush($emailAddress->getAccount());
     $transport = \Swift_MailTransport::newInstance();
     $logger = new \Swift_Plugins_Loggers_EchoLogger();
     $mailer = new \Swift_Mailer($transport);
     $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
     /** @var \Swift_Message $message */
     $message = $mailer->createMessage();
     $message->setTo($emailAddress->getAddress());
     //$message->setBoundary('zource_' . md5(time()));
     $message->setSubject('Test');
     $message->setBody('This is a test.');
     $message->addPart('<q>Here is the message itself</q>', 'text/html');
     $failures = [];
     $result = $mailer->send($message, $failures);
     var_dump($data, $failures, $result, $logger->dump());
     exit;
 }
开发者ID:zource,项目名称:zource,代码行数:29,代码来源:PasswordChanger.php

示例6: initialize

 public function initialize()
 {
     require_once TD_INC . 'swift/swift_required.php';
     if ($this->config['transport'] == 'smtp') {
         $this->transport = Swift_SmtpTransport::newInstance($this->config['smtp_host']);
         if ($this->config['smtp_port']) {
             $this->transport->setPort($this->config['smtp_port']);
         }
         if ($this->config['smtp_encryption']) {
             $this->transport->setEncryption($this->config['smtp_encryption']);
         }
         if ($this->config['smtp_user']) {
             $this->transport->setUsername($this->config['smtp_user']);
         }
         if ($this->config['smtp_pass']) {
             $this->transport->setPassword($this->config['smtp_pass']);
         }
         if ($this->config['smtp_timeout']) {
             $this->transport->setTimeout($this->config['smtp_timeout']);
         }
     } elseif ($this->config['transport'] == 'sendmail') {
         $this->transport = Swift_SendmailTransport::newInstance();
         if ($this->config['sendmail_command']) {
             $this->transport->setCommand($this->config['sendmail_command']);
         }
     } elseif ($this->config['transport'] == 'mail') {
         $this->transport = Swift_MailTransport::newInstance();
     }
     $this->mailer = Swift_Mailer::newInstance($this->transport);
 }
开发者ID:purna89,项目名称:TrellisDesk,代码行数:30,代码来源:class_email.php

示例7: sendEmail

 /**
  * Send the activation email
  *
  * @param \UserModule\Entity\User $from
  * @param \UserModule\Entity\User $to
  * @param string $subject
  * @param string $emailContent
  * @return mixed
  */
 public function sendEmail(UserEntity $from, UserEntity $to, $subject, $emailContent)
 {
     $transport = \Swift_MailTransport::newInstance();
     $mailer = \Swift_Mailer::newInstance($transport);
     $message = \Swift_Message::newInstance($subject)->setFrom(array($from->getEmail() => $from->getFullName()))->setTo(array($to->getEmail() => $to->getFullName()))->setBody($emailContent, 'text/html');
     return $mailer->send($message);
 }
开发者ID:code-ph0y,项目名称:ppi-user-module,代码行数:16,代码来源:Email.php

示例8: send

 function send()
 {
     if ($this->current_transport === false) {
         $this->current_transport = \Swift_MailTransport::newInstance(null);
     }
     return \Swift_Mailer::newInstance($this->current_transport)->send($this);
 }
开发者ID:ramainen,项目名称:doit-cms,代码行数:7,代码来源:doitmessage.class.php

示例9: do_swift_mail

function do_swift_mail($my_smtp_ary, $my_to_ary, $my_subject_str, $my_message_str, $my_from_ary, $my_replyto_str)
{
    // 7/5/10 - per Kurt Jack
    require_once 'lib/swift_required.php';
    if (!empty($my_smtp_ary)) {
        // SMTP?
        $transport = Swift_SmtpTransport::newInstance($my_smtp_ary[0], $my_smtp_ary[1], $my_smtp_ary[2])->setUsername($my_smtp_ary[3])->setPassword($my_smtp_ary[4]);
    } else {
        // php mail
        $transport = Swift_MailTransport::newInstance();
        // Create the php mail Transport
    }
    $mailer = Swift_Mailer::newInstance($transport);
    // Create the Mailer using your created Transport
    $message = Swift_Message::newInstance($my_subject_str)->setFrom($my_from_ary[0])->setTo($my_to_ary)->addReplyTo(trim($my_replyto_str))->setBody($my_message_str);
    //		if ((count($my_from_ary)>0) && (strtoupper(trim(@$my_from_ary[1]=="B")))){	  										// 1/10/11 - hide other addee's?
    if (count($my_from_ary) > 1 && strtoupper(substr(trim(@$my_from_ary[1]), 0, 1) == "B")) {
        // 1/10/11 - hide other addee's?
        $numSent = $mailer->batchSend($message);
        // yes - batchSend hides them
    } else {
        $numSent = $mailer->send($message);
        // no - conventional send
    }
    return $numSent;
}
开发者ID:sharedgeo,项目名称:TicketsCAD-SharedGeo-Dev,代码行数:26,代码来源:smtp.inc.php

示例10: getTransport

 /**
  * @return mixed
  */
 private function getTransport()
 {
     if (null === $this->smtp) {
         return \Swift_MailTransport::newInstance();
     }
     return \Swift_SmtpTransport::newInstance($this->smtp['host'], $this->smtp['port'], $this->smtp['security'])->setUsername($this->smtp['username'])->setPassword($this->smtp['password']);
 }
开发者ID:kangkot,项目名称:bldr,代码行数:10,代码来源:NotifyTask.php

示例11: cdashmail

function cdashmail($to, $subject, $body, $headers = false)
{
    if (empty($to)) {
        add_log('Cannot send email. Recipient is not set.', 'cdashmail', LOG_ERR);
        return false;
    }
    global $CDASH_USE_SENDGRID;
    if ($CDASH_USE_SENDGRID) {
        return _cdashsendgrid($to, $subject, $body);
    }
    $to = explode(', ', $to);
    global $CDASH_EMAIL_FROM, $CDASH_EMAIL_REPLY;
    $message = Swift_Message::newInstance()->setTo($to)->setSubject($subject)->setBody($body)->setFrom(array($CDASH_EMAIL_FROM => 'CDash'))->setReplyTo($CDASH_EMAIL_REPLY)->setContentType('text/plain')->setCharset('UTF-8');
    global $CDASH_EMAIL_SMTP_HOST, $CDASH_EMAIL_SMTP_PORT, $CDASH_EMAIL_SMTP_ENCRYPTION, $CDASH_EMAIL_SMTP_LOGIN, $CDASH_EMAIL_SMTP_PASS;
    if (is_null($CDASH_EMAIL_SMTP_HOST)) {
        // Use the PHP mail() function.
        $transport = Swift_MailTransport::newInstance();
    } else {
        // Use an SMTP server to send mail.
        $transport = Swift_SmtpTransport::newInstance($CDASH_EMAIL_SMTP_HOST, $CDASH_EMAIL_SMTP_PORT, $CDASH_EMAIL_SMTP_ENCRYPTION);
        if (!is_null($CDASH_EMAIL_SMTP_LOGIN) && !is_null($CDASH_EMAIL_SMTP_PASS)) {
            $transport->setUsername($CDASH_EMAIL_SMTP_LOGIN)->setPassword($CDASH_EMAIL_SMTP_PASS);
        }
    }
    $mailer = Swift_Mailer::newInstance($transport);
    return $mailer->send($message) > 0;
}
开发者ID:kitware,项目名称:cdash,代码行数:27,代码来源:cdashmail.php

示例12: send

 static function send($title, $body, $to_array, $attachment = null, $log = true)
 {
     $model = Config::find()->one();
     // Create the message
     $message = \Swift_Message::newInstance()->setSubject($title)->setFrom(array($model->from_email => $model->from_name))->setTo($to_array)->setBody($body);
     // Optionally add any attachments
     if ($attachment) {
         if (is_array($attachment)) {
             foreach ($attachment as $file) {
                 $message = $message->attach(Swift_Attachment::fromPath($file));
             }
         } else {
             $message = $message->attach(Swift_Attachment::fromPath($attachment));
         }
     }
     // Create the Transport
     switch ($model->type) {
         case 1:
             $transport = \Swift_SmtpTransport::newInstance($model->smtp, $model->port > 0 ?: 25)->setUsername($model->from_email)->setPassword($model->pass);
             break;
         case 2:
             $transport = \Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
             break;
         case 3:
             $transport = \Swift_MailTransport::newInstance();
             break;
     }
     $mailer = \Swift_Mailer::newInstance($transport);
     $result = $mailer->send($message);
     //log send mail
     if (true === $log) {
         static::log($to_array, $title, $body, $attachment);
     }
 }
开发者ID:rocketyang,项目名称:mincms,代码行数:34,代码来源:Mailer.php

示例13: index

 public function index()
 {
     //Create the Transport. I created it using the gmail configuration
     //    $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465,'ssl')
     //      ->setUsername('test@gmail.com')
     //      ->setPassword('*****');
     // You could alternatively use a different transport such as Sendmail or Mail:
     //Sendmail:
     //    $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
     //Mail
     $transport = Swift_MailTransport::newInstance();
     //Create the message
     $message = Swift_Message::newInstance();
     //Give the message a subject
     $message->setSubject('send mail test')->setFrom('youremail@gmail.com')->setTo('amritms@gmail.com')->setBody('using php Here is the message sent with swiftmailer ')->addPart('<q>just php mail Here is the message sent with swiftmailer</q>', 'text/html');
     //Create the Mailer using your created Transport
     $mailer = Swift_Mailer::newInstance($transport);
     //Send the message
     $result = $mailer->send($message);
     if ($result) {
         echo "Email sent successfully";
     } else {
         echo "Email failed to send";
     }
 }
开发者ID:beingjungshahi,项目名称:theexcursionnepal,代码行数:25,代码来源:swiftmailer.php

示例14: emailer

 function emailer($sendto, $recipientname, $emailbody, $subject)
 {
     //Create the Transport
     $transport = Swift_MailTransport::newInstance();
     /*
     You could alternatively use a different transport such as Sendmail or Mail:
     
     //Sendmail
     $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
     
     //Mail
     $transport = Swift_MailTransport::newInstance();
     */
     //Create the message
     $message = Swift_Message::newInstance();
     //Give the message a subject
     $message->setSubject($subject)->setFrom(array('noreply@domain.com' => 'CHH IT Team'))->setTo(array($sendto => $recipientname))->setBody('Here is the message itself')->addPart($emailbody, 'text/html');
     //Create the Mailer using your created Transport
     $mailer = Swift_Mailer::newInstance($transport);
     //Send the message
     $result = $mailer->send($message);
     if ($result) {
         echo "Email sent successfully";
     } else {
         echo "Email failed to send";
     }
 }
开发者ID:iamremiel,项目名称:hello-there,代码行数:27,代码来源:Welcome.php

示例15: index

 function index()
 {
     //Create the Transport
     $transport = Swift_MailTransport::newInstance();
     /*
     You could alternatively use a different transport such as Sendmail or Mail:
     
     //Sendmail
     $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
     
     //Mail
     $transport = Swift_MailTransport::newInstance();
     */
     //Create the message
     $message = Swift_Message::newInstance();
     //Give the message a subject
     $message->setSubject('Account Verification')->setFrom(array('noreply@domain.com' => 'CHH IT Team'))->setTo(array('iamremiel@gmail.com' => 'Remmar'))->setBody('Here is the message itself')->addPart('<q>Here is the message itself</q>', 'text/html');
     //Create the Mailer using your created Transport
     $mailer = Swift_Mailer::newInstance($transport);
     //Send the message
     $result = $mailer->send($message);
     if ($result) {
         echo "Email sent successfully";
     } else {
         echo "Email failed to send";
     }
 }
开发者ID:iamremiel,项目名称:hello-there,代码行数:27,代码来源:Swiftmail.php


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