本文整理汇总了PHP中Swift_SmtpTransport::setUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift_SmtpTransport::setUsername方法的具体用法?PHP Swift_SmtpTransport::setUsername怎么用?PHP Swift_SmtpTransport::setUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swift_SmtpTransport
的用法示例。
在下文中一共展示了Swift_SmtpTransport::setUsername方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getErrors
public function getErrors(Config $cfg)
{
$i18n = Localization::getTranslator();
$walletSettings = [];
$emailSettings = [];
$providerClass = '';
try {
$provider = $cfg->getWalletProvider();
$providerClass = get_class($provider);
$provider->verifyOwnership();
} catch (Exception $e) {
if (strpos($providerClass, 'CoinbaseWallet') !== false) {
$walletSettings[] = ['id' => '#wallet-coinbaseApiKey-error', 'error' => $e->getMessage()];
} else {
$walletSettings[] = ['id' => '#wallet-id-error', 'error' => $e->getMessage()];
}
}
try {
$t = new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl');
$t->setUsername($cfg->getEmailUsername())->setPassword($cfg->getEmailPassword())->start();
} catch (Exception $e) {
$emailSettings[] = ['id' => '#email-username-error', 'error' => $e->getMessage()];
}
$errors = [];
if (!empty($pricingSettings)) {
$errors['#pricing-settings'] = self::getPricingErrorsFromConfig($cfg);
}
if (!empty($walletSettings)) {
$errors['#wallet-settings'] = $walletSettings;
}
if (!empty($emailSettings)) {
$errors['#email-settings'] = $emailSettings;
}
return $errors;
}
示例2: init
/**
* Initialize the component
*/
public function init()
{
$this->initAutoloader($this->swiftBasePath);
$this->transport = Swift_SmtpTransport::newInstance($this->host, $this->port, $this->security);
$this->transport->setUsername($this->username)->setPassword($this->password);
parent::init();
}
示例3: connect
/**
* Connect to Mail server
*
* @param array $config
* @return boolean
*/
public function connect(array $config)
{
// Create the Transport
$this->mailer = new \Swift_SmtpTransport($config['server'], $config['port'], sizeof($config['secure']) > 0 ? $config['secure'] : null);
$this->mailer->setUsername($config['username']);
$this->mailer->setPassword($config['password']);
$this->mailer->start();
return $this->mailer->isStarted();
}
示例4: send
public function send()
{
$smtpTransport = new \Swift_SmtpTransport($this->spoolMailerParam('host'), $this->spoolMailerParam('port'));
$smtpTransport->setUsername($this->spoolMailerParam('username'));
$smtpTransport->setPassword($this->spoolMailerParam('password'));
$this->spool->flushQueue($smtpTransport);
}
示例5: testReport
public function testReport()
{
// Arrange.
$transport = new \Swift_SmtpTransport();
$transport->setHost('mailtrap.io');
$transport->setPort(2525);
$transport->setUsername(getenv('MAILTRAP_USERNAME'));
$transport->setPassword(getenv('MAILTRAP_PASSWORD'));
$mailer = new Swift_Mailer($transport);
$message = new Swift_Message();
$message->addTo('craig.michael.morris@gmail.com');
$message->setFrom('craig.michael.morris@gmail.com');
$body = new Body(new VarCloner(), new CliDumper());
$compiler = new Compiler(new CommonMarkConverter(), new CssToInlineStyles());
$email = new Email($mailer, $message, $body, $compiler);
$exception = new DomainException('Testing a domain exception');
$extra = ['only' => 'testing12321'];
// Act.
$email->report($exception, $extra);
// Assert.
$message = $this->mailtrap->get('inboxes/' . getenv('MAILTRAP_INBOX') . '/messages')->json()[0];
$this->assertSame('Exception: Testing a domain exception', $message['subject']);
$this->assertContains('$email->report($exception, $extra);', $message['text_body']);
$this->assertContains("exception 'DomainException' with message 'Testing a domain exception'", $message['text_body']);
$this->assertContains('{main}', $message['text_body']);
$this->assertContains('"only" => "testing12321"', $message['text_body']);
$this->assertContains('_SERVER', $message['text_body']);
}
示例6: init
protected function init($config = array())
{
$transport = new \Swift_SmtpTransport($this->smtpHost, $this->smtpPort, $this->smtpSecure);
$transport->setUsername($this->smtpUser);
$transport->setPassword($this->smtpPassword);
$this->mailer = new \Swift_Mailer($transport);
return parent::init();
}
示例7: createMailer
/**
* Changes mailer configuration on runtime
*
* @param MailerConfiguration $mailerConfiguration
*
* @return \Swift_Mailer
*/
protected function createMailer(MailerConfiguration $mailerConfiguration)
{
$transport = new \Swift_SmtpTransport();
$transport->setHost($mailerConfiguration->getHost());
$transport->setPort($mailerConfiguration->getPort());
$transport->setUsername($mailerConfiguration->getUser());
$transport->setPassword($mailerConfiguration->getPass());
return \Swift_Mailer::newInstance($transport);
}
示例8: __construct
/**
* Mailer constructor.
* @param $configuration
*/
public function __construct($configuration)
{
$transport = new \Swift_SmtpTransport($configuration["host"], $configuration["port"]);
$transport->setUsername($configuration["username"]);
$transport->setPassword($configuration["password"]);
$transport->setAuthMode($configuration["auth_mode"]);
$transport->setEncryption($configuration["encryption"]);
$this->mailer = new \Swift_Mailer($transport);
$this->debugMail = isset($configuration["debug_email"]) ? $configuration["debug_email"] : null;
}
示例9:
function send_breakin_alert($email, $password)
{
$transporter = new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl');
$transporter->setUsername('');
$transporter->setPassword('');
$message = new Swift_Message($transporter);
$message->setTo(array($email => $email));
$message->setSubject("Note to Myself - Break-in Attempt");
$message->addPart("Your password has been reset after 3 failed log-in attempts.</br>Your new password is <strong>{$password}</strong>", 'text/html');
$message->setFrom("", "");
$mailer = new Swift_Mailer($transporter);
$mailer->send($message);
}
示例10: __getSwiftMailer
/**
* @param $from
* @return \Swift_Mailer
*/
protected function __getSwiftMailer($from)
{
if (!isset($this->swiftMailers[$hash = md5(json_encode($from))])) {
$transport = new \Swift_SmtpTransport(isset($from['smtpHost']) ? $from['smtpHost'] : '127.0.0.1', isset($from['smtpPort']) ? $from['smtpPort'] : 25, isset($from['smtpSecure']) ? $from['smtpSecure'] : false);
if (isset($from['smtpUser'])) {
$transport->setUsername($from['smtpUser']);
}
if (isset($from['smtpPassword'])) {
$transport->setPassword($from['smtpPassword']);
}
$this->swiftMailers[$hash] = new \Swift_Mailer($transport);
}
return $this->swiftMailers[$hash];
}
示例11: createSmtpMailer
/**
* @param string|null $host
* @param int|null $port
* @param array|null $headers
* @param string|null $username
* @param string|null $password
* @param string|null $security
* @return CM_Mail_Mailer
*/
public function createSmtpMailer($host = null, $port = null, array $headers = null, $username = null, $password = null, $security = null)
{
$host = null !== $host ? (string) $host : 'localhost';
$port = null !== $port ? (int) $port : 25;
$headers = null !== $headers ? (array) $headers : [];
$security = null !== $security ? (string) $security : null;
$transport = new Swift_SmtpTransport($host, $port, $security);
if (null !== $username) {
$transport->setUsername((string) $username);
}
if (null !== $password) {
$transport->setPassword((string) $password);
}
return new CM_Mail_Mailer($transport, $headers);
}
示例12: startUp
static function startUp(KernelInterface $kernel, ModuleInfo $moduleInfo)
{
$kernel->onRegisterServices(function (InjectorInterface $injector) {
$injector->delegate(Swift_Mailer::class, function () use($injector) {
$transport = new \Swift_SmtpTransport(env('EMAIL_SMTP_HOST', 'localhost'), env('EMAIL_SMTP_PORT', 25));
if (env('EMAIL_SMTP_AUTH')) {
$transport->setUsername(env('EMAIL_SMTP_USERNAME'))->setPassword(env('EMAIL_SMTP_PASSWORD'));
}
$mailer = new Swift_Mailer($transport);
$logger = new Swift_Plugins_Loggers_ArrayLogger(self::MAX_LOG_SIZE);
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
// Create run-time custom property to allow easy access to the logger.
$mailer->logger = $logger;
return $mailer;
});
});
}
示例13: execute
public function execute(Request $request, $function)
{
switch ($function) {
case 'verify-smtp':
$smtp = new \Swift_SmtpTransport($request->input('smtp-server'), $request->input('smtp-port'), $request->input('smtp-ssl'));
$smtp->setUsername($request->input('smtp-username'));
$smtp->setPassword($request->input('smtp-password'));
$smtp->start();
$this->ajax_result['errno'] = 0;
$this->ajax_result['html'] = 'OK';
$this->ajax_result['smtp'] = $smtp->isStarted();
// $this -> ajax_result['errno'] = time() % 2;
// $this -> ajax_result['errmsg'] = 'chujnia jakas sie wydazyla';
// $this -> ajax_result['html'] = 'chujnia jakas sie wydazyla';
break;
}
echo json_encode($this->ajax_result);
}
示例14: __construct
public function __construct(array $options = array())
{
$swiftTransort = new \Swift_SmtpTransport();
$swiftTransort->setHost($options['smtp']);
$swiftTransort->setPort($options['port']);
if (isset($options['encryption'])) {
$swiftTransort->setEncryption($options['encryption']);
}
if (isset($options['username'])) {
$swiftTransort->setUsername($options['username']);
}
if (isset($options['password'])) {
$swiftTransort->setPassword($options['password']);
}
if (isset($options['auth_mode'])) {
$swiftTransort->setAuthMode($options['auth_mode']);
}
$this->_mailer = new \Swift_Mailer($swiftTransort);
}
示例15: connect
/**
* Connect to Mail server
*
* @param array $config
* @throws \RuntimeException
* @return \Swift_SmtpTransport
*/
public function connect(array $config)
{
// save config
$this->config = $config;
try {
if (!$this->connect) {
$this->connect = new \Swift_SmtpTransport($config['server'], $config['port'], $config['socket']);
$this->connect->setUsername($config['username']);
$this->connect->setPassword($config['password']);
$this->connect->start();
}
if ($this->connect->isStarted() === false) {
throw new MailException('Mail connection failed! Check configurations');
}
return $this;
} catch (\Exception $e) {
throw new MailException($e->getMessage());
}
}