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