本文整理汇总了PHP中Swift_MailTransport类的典型用法代码示例。如果您正苦于以下问题:PHP Swift_MailTransport类的具体用法?PHP Swift_MailTransport怎么用?PHP Swift_MailTransport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Swift_MailTransport类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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('[email protected]' => 'Site Name'));
$message->setTo(array($info['email'] => $info['username']));
$message->setBody($body_plain_txt);
$message->addPart($body, 'text/html');
echo "WHAT";
echo $message;
//$to = "[email protected]";
//$sub = "Te_subject_of_your_email";
//$mess = "Dear User, \r\n\r\n";
//$mess .= "This is your message \r\n";
//$headers = "From: [email protected] \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('[email protected]', '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('[email protected]')
// ->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('[email protected]')->setTo('[email protected]')->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('[email protected]' => '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('[email protected]' => 'CHH IT Team'))->setTo(array('[email protected]' => '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
示例16: setTransport
/**
* Define the transport method
* @param object $okt
*/
protected function setTransport()
{
switch ($this->okt->config->email['transport']) {
default:
case 'mail':
$this->transport = Swift_MailTransport::newInstance();
break;
case 'smtp':
$this->transport = Swift_SmtpTransport::newInstance($this->okt->config->email['smtp']['host'], $this->okt->config->email['smtp']['port']);
if (!empty($this->okt->config->email['smtp']['username'])) {
$this->transport->setUsername($this->okt->config->email['smtp']['username']);
}
if (!empty($this->okt->config->courriel['smtp']['password'])) {
$this->transport->setPassword($this->okt->config->email['smtp']['password']);
}
break;
case 'sendmail':
$command = '/usr/sbin/exim -bs';
if (!empty($this->okt->config->email['sendmail'])) {
$command = $this->okt->config->email['sendmail'];
}
$this->transport = Swift_SendmailTransport::newInstance($command);
break;
}
}
开发者ID:jewelhuq,项目名称:okatea,代码行数:29,代码来源:class.oktMail.php
示例17: send
/**
* Send a mail
*
* @param string $subject
* @param string $content
* @return bool|string false is everything was fine, or error string
*/
public function send($subject, $content)
{
try {
// Test with custom SMTP connection
if ($this->smtp_checked) {
// Retrocompatibility
if (Tools::strtolower($this->encryption) === 'off') {
$this->encryption = false;
}
$smtp = Swift_SmtpTransport::newInstance($this->server, $this->port, $this->encryption);
$smtp->setUsername($this->login);
$smtp->setpassword($this->password);
$smtp->setTimeout(5);
$swift = Swift_Mailer::newInstance($smtp);
} else {
// Test with normal PHP mail() call
$swift = Swift_Mailer::newInstance(Swift_MailTransport::newInstance());
}
$message = Swift_Message::newInstance();
$message->setFrom($this->email)->setTo('no-reply@' . Tools::getHttpHost(false, false, true))->setSubject($subject)->setBody($content);
$message = new Swift_Message($subject, $content, 'text/html');
if (@$swift->send($message)) {
$result = true;
} else {
$result = 'Could not send message';
}
$swift->disconnect();
} catch (Swift_SwiftException $e) {
$result = $e->getMessage();
}
return $result;
}
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:39,代码来源:mail.php
示例18: action_index
public function action_index()
{
$this->template->title = __('Contact');
$this->template->content = View::factory('page/contact')->bind('errors', $errors);
// Validate the required fields
$data = Validate::factory($_POST)->filter('name', 'trim')->rule('name', 'not_empty')->filter('email', 'trim')->rule('email', 'not_empty')->rule('email', 'email')->filter('message', 'trim')->filter('message', 'Security::xss_clean')->filter('message', 'strip_tags')->rule('message', 'not_empty');
if ($data->check()) {
// Load Swift Mailer
require Kohana::find_file('vendor', 'swiftmailer/lib/swift_required');
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
// Get the email config
$config = Kohana::config('site.contact');
$recipient = $config['recipient'];
$subject = $config['subject'];
// Create an email message
$message = Swift_Message::newInstance()->setSubject(__($subject, array(':name' => $data['name'])))->setFrom(array($data['email'] => $data['name']))->setTo($recipient)->addPart($data['message'], 'text/plain');
// Send the message
Swift_Mailer::newInstance($transport)->send($message);
// Set the activity and flash message
Activity::set(Activity::SUCCESS, __('Message sent from :email', array(':email' => $data['email'])));
Message::set(Message::SUCCESS, __('Message successfully sent.'));
// Redirect to prevent POST refresh
$this->request->redirect($this->request->uri);
}
if ($errors = $data->errors('contact')) {
// Set the error flash message
Message::set(Message::ERROR, __('Please correct the errors.'));
}
$_POST = $data->as_array();
}
开发者ID:Oaks,项目名称:kohana3-examples,代码行数:31,代码来源:contact.php
示例19: send
/**
* Send an email
* @param SwiftMessage $message
* @return mixed - TRUE on success, or an array of failed addresses on error.
*/
static function send($message)
{
try {
require_once 'include/swiftmailer/swift_required.php';
if (defined('SMTP_SERVER')) {
$port = defined('SMTP_PORT') ? SMTP_PORT : 25;
$transport = Swift_SmtpTransport::newInstance(SMTP_SERVER, $port);
if (defined('SMTP_USERNAME') && SMTP_USERNAME) {
$transport->setUsername(SMTP_USERNAME);
}
if (defined('SMTP_PASSWORD') && SMTP_PASSWORD) {
$transport->setPassword(SMTP_PASSWORD);
}
if (defined('SMTP_ENCRYPTION') && SMTP_ENCRYPTION) {
$transport->setEncryption(SMTP_ENCRYPTION);
}
} else {
$transport = Swift_MailTransport::newInstance();
}
$mailer = Swift_Mailer::newInstance($transport);
$failures = array();
$numSent = $mailer->send($message, $failures);
if (empty($failures) && $numSent) {
return TRUE;
}
return $failures;
} catch (Exception $e) {
trigger_error("Could not send email: " . $e->getMessage(), E_USER_WARNING);
return FALSE;
}
}
开发者ID:vanoudt,项目名称:jethro-pmm,代码行数:36,代码来源:emailer.class.php
示例20: getMailer
protected function getMailer()
{
if (empty($this->mailer)) {
require_once PATH_SYSTEM . "/vendors/Swift-4.0.4/lib/swift_required.php";
switch ($this->emailMode) {
case 'smtp':
//Create the Transport
$transport = Swift_SmtpTransport::newInstance($this->emailConfig['host'], $this->emailConfig['port']);
if (!empty($this->emailConfig['user'])) {
$transport->setUsername($this->emailConfig['user']);
}
if (!empty($this->emailConfig['password'])) {
$transport->setPassword($this->emailConfig['password']);
}
if (!empty($this->emailConfig['timeout'])) {
$transport->setTimeout($this->emailConfig['timeout']);
}
if (!empty($this->emailConfig['encryption'])) {
$transport->setEncryption($this->emailConfig['encryption']);
}
$this->mailer = Swift_Mailer::newInstance($transport);
break;
case 'sendmail':
$transport = Swift_SendmailTransport::newInstance(!empty($this->emailConfig['pathToSendmail']) ? $this->emailConfig['pathToSendmail'] : '/usr/sbin/sendmail -bs');
$this->mailer = Swift_Mailer::newInstance($transport);
break;
default:
case 'mail':
$transport = Swift_MailTransport::newInstance();
$this->mailer = Swift_Mailer::newInstance($transport);
break;
}
}
return $this->mailer;
}
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:35,代码来源:Email.php
注:本文中的Swift_MailTransport类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论