本文整理汇总了PHP中Swift_SmtpTransport::start方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift_SmtpTransport::start方法的具体用法?PHP Swift_SmtpTransport::start怎么用?PHP Swift_SmtpTransport::start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swift_SmtpTransport
的用法示例。
在下文中一共展示了Swift_SmtpTransport::start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: 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());
}
}
示例4: testEmailServerConnectionAction
/**
* Tests mail transport settings
*
* @param Request $request
*
* @return JsonResponse
*/
protected function testEmailServerConnectionAction(Request $request)
{
$dataArray = array('success' => 0, 'error' => '');
if ($this->factory->getUser()->isAdmin()) {
$settings = $request->request->all();
$transport = $settings['transport'];
switch ($transport) {
case 'mautic.transport.mandrill':
$mailer = new MandrillTransport();
break;
case 'mautic.transport.sendgrid':
$mailer = new SendgridTransport();
break;
case 'mautic.transport.amazon':
$mailer = new AmazonTransport();
break;
case 'mautic.transport.postmark':
$mailer = new PostmarkTransport();
break;
case 'gmail':
$mailer = new \Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl');
break;
case 'smtp':
$mailer = new \Swift_SmtpTransport($settings['host'], $settings['port'], $settings['encryption']);
break;
}
if (!empty($mailer)) {
if (empty($settings['password'])) {
$settings['password'] = $this->factory->getParameter('mailer_password');
}
$mailer->setUsername($settings['user']);
$mailer->setPassword($settings['password']);
$logger = new \Swift_Plugins_Loggers_ArrayLogger();
$mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
try {
$mailer->start();
$translator = $this->factory->getTranslator();
if ($settings['send_test'] == 'true') {
$message = new \Swift_Message($translator->trans('mautic.core.config.form.mailer.transport.test_send.subject'), $translator->trans('mautic.core.config.form.mailer.transport.test_send.body'));
$user = $this->factory->getUser();
$message->setFrom(array($settings['from_email'] => $settings['from_name']));
$message->setTo(array($user->getEmail() => $user->getFirstName() . ' ' . $user->getLastName()));
$mailer->send($message);
}
$dataArray['success'] = 1;
$dataArray['message'] = $translator->trans('mautic.core.success');
} catch (\Exception $e) {
$dataArray['message'] = $e->getMessage() . '<br />' . $logger->dump();
}
}
}
return $this->sendJsonResponse($dataArray);
}