本文整理匯總了PHP中Zend\Mail\Transport\Smtp::setOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Smtp::setOptions方法的具體用法?PHP Smtp::setOptions怎麽用?PHP Smtp::setOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Mail\Transport\Smtp
的用法示例。
在下文中一共展示了Smtp::setOptions方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: flush
public function flush()
{
$this->transport->setOptions($this->getSmtpOptions());
foreach ($this->queue as $message) {
$this->transport->send($message);
}
$this->queue = [];
}
示例2: createService
/**
* Create service
*
* @param ServiceLocatorInterface $sm Service manager
*
* @return mixed
*/
public function createService(ServiceLocatorInterface $sm)
{
// Load configurations:
$config = $sm->get('VuFind\\Config')->get('config');
// Create mail transport:
$settings = ['host' => $config->Mail->host, 'port' => $config->Mail->port];
if (isset($config->Mail->username) && isset($config->Mail->password)) {
$settings['connection_class'] = 'login';
$settings['connection_config'] = ['username' => $config->Mail->username, 'password' => $config->Mail->password];
if (isset($config->Mail->secure)) {
// always set user defined secure connection
$settings['connection_config']['ssl'] = $config->Mail->secure;
} else {
// set default secure connection based on configured port
if ($settings['port'] == '587') {
$settings['connection_config']['ssl'] = 'tls';
} elseif ($settings['port'] == '487') {
$settings['connection_config']['ssl'] = 'ssl';
}
}
}
$transport = new Smtp();
$transport->setOptions(new SmtpOptions($settings));
// Create service:
return new \VuFind\Mailer\Mailer($transport);
}
示例3: getMailerObject
public static function getMailerObject()
{
$response = array();
$response['mail'] = new Message();
$response['mail']->setEncoding(APP_CHARSET);
if (strcasecmp(Config::get('concrete.mail.method'), 'smtp') == 0) {
$config = array('host' => Config::get('concrete.mail.methods.smtp.server'));
$username = Config::get('concrete.mail.methods.smtp.username');
$password = Config::get('concrete.mail.methods.smtp.password');
if ($username != '') {
$config['connection_class'] = 'login';
$config['connection_config'] = array();
$config['connection_config']['username'] = $username;
$config['connection_config']['password'] = $password;
}
$port = Config::get('concrete.mail.methods.smtp.port', '');
if ($port != '') {
$config['port'] = $port;
}
$encr = Config::get('concrete.mail.methods.smtp.encryption', '');
if ($encr != '') {
$config['connection_config']['ssl'] = $encr;
}
$transport = new SmtpTransport();
$options = new SmtpOptions($config);
$transport->setOptions($options);
$response['transport'] = $transport;
} else {
$response['transport'] = new SendmailTransport();
}
return $response;
}
示例4: send
protected function send()
{
try {
$message = new Message();
$para = array_filter(explode(";", str_replace(array(" ", ","), array("", ";"), $this->dados["para"])));
$message->addTo($para)->addFrom($this->dados["de"]["email"], $this->dados["de"]["nome"])->setSubject($this->dados["assunto"])->addReplyTo($this->dados["replay"]);
$transport = new SmtpTransport();
$options = new SmtpOptions(array('host' => 'mail.pessoaweb.com.br', 'connection_class' => 'login', 'connection_config' => array('username' => 'dispatch@pessoaweb.com.br', 'password' => 'd1i2s3p4atch'), 'port' => 587));
$html = new MimePart($this->dados["body"]);
$html->type = "text/html";
$html->charset = "UTF-8";
$body = new MimeMessage();
if (isset($this->dados["attachment"])) {
foreach ($this->dados["attachment"] as $valor) {
$attachment = new MimePart($valor["arquivo"]);
$attachment->filename = $valor["titulo"];
if (isset($valor["tipo"])) {
$attachment->type = $valor["tipo"];
}
$attachment->disposition = Mime::DISPOSITION_ATTACHMENT;
$attachment->encoding = Mime::ENCODING_BASE64;
$body->setParts(array($attachment));
}
}
$body->addPart($html);
$message->setBody($body);
$transport->setOptions($options);
$transport->send($message);
return $transport;
} catch (\Exception $e) {
debug(array("email" => $e->getMessage()), true);
}
}
示例5: getTransport
public function getTransport()
{
$transport = new SmtpTransport();
$options = new SmtpOptions(array('name' => 'bitweb.ee', 'host' => 'smtp.gmail.com', 'port' => '25', 'connection_class' => 'login', 'connection_config' => array('ssl' => 'tls', 'username' => 'kristjan.andresson@bitweb.ee', 'password' => 'erkinool123')));
$transport->setOptions($options);
return $transport;
}
示例6: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
$transport = new Smtp();
$transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
return $transport;
}
示例7: sendMail
/**
* Sends a mail with the given data from the AppMailAccount
* @param string $to
* @param string $subject
* @param string $content
*/
public function sendMail(string $to, string $subject, string $content, array $files = [])
{
$content .= "\n\nThis is an automated mail. Please don't respond.";
$text = new Mime\Part($content);
$text->type = 'text/plain';
$text->charset = 'utf-8';
$text->disposition = Mime\Mime::DISPOSITION_INLINE;
$parts[] = $text;
foreach ($files as $filePath) {
$fileContent = file_get_contents($filePath);
$attachment = new Mime\Part($fileContent);
$attachment->type = 'image/' . pathinfo($filePath, PATHINFO_EXTENSION);
$attachment->filename = basename($filePath);
$attachment->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
$attachment->encoding = Mime\Mime::ENCODING_BASE64;
$parts[] = $attachment;
}
$mime = new Mime\Message();
$mime->setParts($parts);
$appMailData = $this->getAppMailData();
$message = new Message();
$message->addTo($to)->addFrom($appMailData->getAdress())->setSubject($subject)->setBody($mime)->setEncoding('utf-8');
$transport = new SmtpTransport();
$options = new SmtpOptions(['name' => $appMailData->getHost(), 'host' => $appMailData->getHost(), 'connection_class' => 'login', 'connection_config' => ['username' => $appMailData->getLogin(), 'password' => $appMailData->getPassword()]]);
$transport->setOptions($options);
$transport->send($message);
}
示例8: __construct
/**
* Prepares the \Zend\Mail module
*/
public function __construct()
{
$beehubConfig = \BeeHub::config();
$config = $beehubConfig['email'];
if (!empty($config['host'])) {
// Configure the transporter for sending through SMTP
$transport = new Mail\Transport\Smtp();
$emailConfig = array('host' => $config['host']);
if (!empty($config['port'])) {
$emailConfig['port'] = $config['port'];
}
if (!empty($config['security'])) {
$emailConfig['connection_config'] = array();
$emailConfig['connection_config']['ssl'] = $config['security'];
}
if (!empty($config['auth_method'])) {
$emailConfig['connection_class'] = $config['auth_method'];
if (!isset($emailConfig['connection_config'])) {
$emailConfig['connection_config'] = array();
}
$emailConfig['connection_config']['username'] = $config['username'];
$emailConfig['connection_config']['password'] = $config['password'];
}
$options = new Mail\Transport\SmtpOptions($emailConfig);
$transport->setOptions($options);
} else {
// Else we use the Sendmail transporter (which actually just uses mail()
$transport = new Mail\Transport\Sendmail();
}
$this->emailer = $transport;
}
示例9: getTransport
public function getTransport()
{
$transport = new SmtpTransport();
$options = new SmtpOptions(array('name' => 'localhost.localdomain', 'host' => $this->smtpHost, 'connection_class' => 'login', 'connection_config' => array('username' => $this->smtpUser, 'password' => $this->smtpPass)));
$transport->setOptions($options);
return $transport;
}
示例10: send
/**
* @param Message $message
*/
public function send(Message $message)
{
if (!count($message->getFrom())) {
$message->setFrom('no-reply@uscaninescentsports.com', 'US Canine Scent Sports');
}
$transport = new Transport\Smtp();
$transport->setOptions($this->transportOptions)->send($message);
}
示例11: setTransport
/**
* set SMTP config
*
* @param array $config
* @return $this
*/
public function setTransport(array $config)
{
$transport = new Smtp();
$options = new SmtpOptions(array('name' => $config['name'], 'host' => $config['host'], 'connection_class' => $config['login'], 'connection_config' => array('username' => $config['user'], 'password' => $config['pass'])));
$transport->setOptions($options);
$this->transport = $transport;
return $this;
}
示例12: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('mail.transport' => function ($serviceManager) {
$config = $serviceManager->get('Config');
$transport = new SmtpTransport();
$transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
return $transport;
}));
}
示例13: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('ZF2Base\\Mail\\Transport' => function ($sm) {
$config = $sm->get('Config');
$transport = new SmtpTransport();
$options = new SmtpOptions($config['mail']);
$transport->setOptions($options);
return $transport;
}));
}
示例14: sendMail
public function sendMail()
{
$message = new Message();
$message->addTo('matthew@zend.com')->addFrom('ralph.schindler@zend.com')->setSubject('Greetings and Salutations!')->setBody("Sorry, I’m going to be late today!");
// Setup SMTP transport using LOGIN authentication
$transport = new SmtpTransport();
$options = new SmtpOptions(array('name' => 'localhost.localdomain', 'host' => '127.0.0.1', 'connection_class' => 'login', 'connection_config' => array('username' => 'user', 'password' => 'pass')));
$transport->setOptions($options);
$transport->send($message);
}
示例15: setSmtp
public function setSmtp()
{
$this->smtp = new Smtp();
if ($this->checkout == true) {
$smptOptions = array('host' => $this->config['smtp_host'], 'port' => $this->config['smtp_port'], 'connection_class' => $this->config['smtp_connection_class'], 'connection_config' => array('username' => $this->config['smtp_username'], 'password' => $this->config['smtp_password'], 'ssl' => 'tls'));
$this->smtp->setOptions(new SmtpOptions($smptOptions));
} else {
$this->smtp->setOptions(new SmtpOptions($this->config['transport']['options']));
}
}