create reusable transporter object using SMTP transport Some antiviruses can block sending with self signed certificate. If this is your case -
176785
function getSmtpTransporter() {
  return nodemailer.createTransport(
    smtpTransport({
      // service: 'tia',
      host: gT.suiteConfig.mailSmtpHost,
      secure: true,

      // secure : false,
      // port: 25,
      auth: {
        user: gT.suiteConfig.mailUser,
        pass: gT.suiteConfig.mailPassword,
      },

      // , tls: {
      //  rejectUnauthorized: false
      // }
    })
  );
}
58199
def append(self, cert):
        

        if not isinstance(cert, x509.Certificate):
            if not isinstance(cert, byte_cls):
                raise TypeError(pretty_message(
                    '''
                    cert must be a byte string or an
                    asn1crypto.x509.Certificate object, not %s
                    ''',
                    type_name(cert)
                ))
            if pem.detect(cert):
                _, _, cert = pem.unarmor(cert)
            cert = x509.Certificate.load(cert)

        if cert.issuer_serial in self._cert_hashes:
            raise DuplicateCertificateError()

        self._cert_hashes.add(cert.issuer_serial)
        self._certs.append(cert)

        return self
1220098
def import_certificate(certificate)
      new_action = {
        'Action' => 'ImportCertificate',
        'Certificate' => certificate
      }
      response = rest_post('/redfish/v1/Managers/1/SecurityService/HttpsCert/', body: new_action)
      response_handler(response)
      true
    end
1290248
def make_action_mailer_use_request_host_and_protocol
      ActionMailer::Base.default_url_options[:protocol] = request.protocol
      ActionMailer::Base.default_url_options[:host] = request.host_with_port
    end
813184
def connection_made(self, transport):
        """"""
        self.port = transport.serial.port
        logger.debug('connection_made: `%s` `%s`', self.port, transport)
        self.transport = transport
        self.connected.set()
        self.disconnected.clear()
312648
function create() {
		// Check form for errors
		if(!$("#privateKey").val() || !$("#recipient").val()) return alert('Missing parameter !');
		if(undefined === $("#amount").val() || !nem.utils.helpers.isTextAmountValid($("#amount").val())) return alert('Invalid amount !');
		if (!nem.model.address.isValid(nem.model.address.clean($("#recipient").val()))) return alert('Invalid recipent address !');

		// Set the private key in common object
		common.privateKey = $("#privateKey").val();

		// Check private key for errors
		if (common.privateKey.length !== 64 && common.privateKey.length !== 66) return alert('Invalid private key, length must be 64 or 66 characters !');
    	if (!nem.utils.helpers.isHexadecimal(common.privateKey)) return alert('Private key must be hexadecimal only !');

		// Set the cleaned amount into transfer transaction object
		transferTransaction.amount = nem.utils.helpers.cleanTextAmount($("#amount").val());

		// Recipient address must be clean (no hypens: "-")
		transferTransaction.recipient = nem.model.address.clean($("#recipient").val());

		// Set message
		transferTransaction.message = $("#message").val();

		// Prepare the updated transfer transaction object
		var transactionEntity = nem.model.transactions.prepare("transferTransaction")(common, transferTransaction, nem.model.network.data.testnet.id);

		// Create a key pair object from private key
		var kp = nem.crypto.keyPair.create(nem.utils.helpers.fixPrivateKey(common.privateKey));

		// Serialize the transaction
		var serialized = nem.utils.serialization.serializeTransaction(transactionEntity);

		// Sign the serialized transaction with keypair object
	    var signature = kp.sign(serialized);

	    // Build the object to send
	    var result = {
	        'data': nem.utils.convert.ua2hex(serialized),
	        'signature': signature.toString()
	    };

	    // Show the object to send in view
	    $("#result").val(JSON.stringify(result));
	}
1000065
private function transport()
    {
        $this->transport = Transport::newInstance($this->smtp->get('host'), $this->smtp->get('port'), $this->smtp->get('encryption'))
            ->setUsername($this->smtp->get('username'))
            ->setPassword($this->smtp->get('password'));

        return $this->transport;
    }
113952
def sanitize_ssl(self):
        """"""
        if self["sslverify"] is True:
            try:
                self["sslverify"] = get_system_cert_file()
            except ValueError:
                try:
                    self["sslverify"] = get_certifi_file()
                except (ValueError, ImportError):
                    try:
                        self["sslverify"] = get_share_file('cacert.pem')
                    except ValueError:
                        pass
1008290
def send(kwargs, opts):
    '''
    
    '''
    opt_keys = (
        'smtp.to',
        'smtp.from',
        'smtp.host',
        'smtp.port',
        'smtp.tls',
        'smtp.username',
        'smtp.password',
        'smtp.subject',
        'smtp.gpgowner',
        'smtp.content',
    )

    config = {}
    for key in opt_keys:
        config[key] = opts.get(key, '')

    config.update(kwargs)

    if not config['smtp.port']:
        config['smtp.port'] = 25

    log.debug('SMTP port has been set to %s', config['smtp.port'])
    log.debug("smtp_return: Subject is '%s'", config['smtp.subject'])

    if HAS_GNUPG and config['smtp.gpgowner']:
        gpg = gnupg.GPG(
            gnupghome=os.path.expanduser(
                '~{0}/.gnupg'.format(config['smtp.gpgowner'])
            ),
            options=['--trust-model always']
        )
        encrypted_data = gpg.encrypt(config['smtp.content'], config['smtp.to'])
        if encrypted_data.ok:
            log.debug('smtp_return: Encryption successful')
            config['smtp.content'] = six.text_type(encrypted_data)
        else:
            log.error(
                'SMTP: Encryption failed, only an error message will be sent'
            )
            config['smtp.content'] = (
                'Encryption failed, the return data was not sent.'
                '\r\n\r\n{0}\r\n{1}'
            ).format(encrypted_data.status, encrypted_data.stderr)

    message = (
        'From: {0}\r\n'
        'To: {1}\r\n'
        'Date: {2}\r\n'
        'Subject: {3}\r\n'
        '\r\n'
        '{4}'
    ).format(
        config['smtp.from'],
        config['smtp.to'],
        formatdate(localtime=True),
        config['smtp.subject'],
        config['smtp.content'],
    )

    log.debug('smtp_return: Connecting to the server...')
    server = smtplib.SMTP(config['smtp.host'], int(config['smtp.port']))

    if config['smtp.tls'] is True:
        server.starttls()
        log.debug('smtp_return: TLS enabled')

    if config['smtp.username'] and config['smtp.password']:
        server.login(config['smtp.username'], config['smtp.password'])
        log.debug('smtp_return: Authenticated')

    server.sendmail(config['smtp.from'], config['smtp.to'], message)
    log.debug('smtp_return: Message sent.')
    server.quit()
687820
def send_mail(recipient, sender, subject="", content="", smtp_host="127.0.0.1", smtp_port=25):
    
    try:
        server = smtplib.SMTP(smtp_host, smtp_port)
    except Exception as e:
        logger = logging.getLogger(__name__)
        logger.warning("cannot create SMTP server: {}".format(e))
        return False

    header = "From: {}\r\nTo: {}\r\nSubject: {}\r\n\r\n".format(sender, recipient, subject)
    server.sendmail(sender, recipient, header + content)

    return True
1057979
def CreateReply(self, **attributes):
        
        return Packet(id=self.id, secret=self.secret,
                      authenticator=self.authenticator, dict=self.dict,
                      **attributes)
1095776
def connection_made(self, transport):
        

        # Save the underlying transport
        self._transport = transport

        # Call connection_made() on the client protocol, passing
        # ourself as the transport
        self._client.connection_made(self)
780417
def create_self_signed_cert():
    """"""
    config_dir = Path(BaseDirectory.xdg_config_home) / 'xenon-grpc'
    config_dir.mkdir(parents=True, exist_ok=True)

    key_prefix = gethostname()
    crt_file = config_dir / ('%s.crt' % key_prefix)
    key_file = config_dir / ('%s.key' % key_prefix)

    if crt_file.exists() and key_file.exists():
        return crt_file, key_file

    logger = logging.getLogger('xenon')
    logger.info("Creating authentication keys for xenon-grpc.")

    # create a key pair
    k = crypto.PKey()
    k.generate_key(crypto.TYPE_RSA, 1024)

    # create a self-signed cert
    cert = crypto.X509()
    cert.get_subject().CN = gethostname()
    cert.set_serial_number(1000)
    cert.gmtime_adj_notBefore(0)
    # valid for almost ten years!
    cert.gmtime_adj_notAfter(10 * 365 * 24 * 3600)
    cert.set_issuer(cert.get_subject())
    cert.set_pubkey(k)
    cert.sign(k, 'sha256')

    open(str(crt_file), "wb").write(
        crypto.dump_certificate(crypto.FILETYPE_PEM, cert))
    open(str(key_file), "wb").write(
        crypto.dump_privatekey(crypto.FILETYPE_PEM, k))

    return crt_file, key_file
557984
def retry(
        transport: 'UDPTransport',
        messagedata: bytes,
        message_id: UDPMessageID,
        recipient: Address,
        stop_event: Event,
        timeout_backoff: Iterable[int],
) -> bool:
    

    async_result = transport.maybe_sendraw_with_result(
        recipient,
        messagedata,
        message_id,
    )

    event_quit = event_first_of(
        async_result,
        stop_event,
    )

    for timeout in timeout_backoff:

        if event_quit.wait(timeout=timeout) is True:
            break

        log.debug(
            'retrying message',
            node=pex(transport.raiden.address),
            recipient=pex(recipient),
            msgid=message_id,
        )

        transport.maybe_sendraw_with_result(
            recipient,
            messagedata,
            message_id,
        )

    return async_result.ready()
897778
def connection_made(self, transport):
        """"""
        self._transport = transport
        self._raw_transport = transport
        if isinstance(transport, asyncio.SubprocessTransport):
            self._transport = transport.get_pipe_transport(0)
1216180
public static function createTransport($transport, array $config)
    {
        $config = new Structure($config);

        switch ($transport) {
            case 'smtp':
                $instance = \Swift_SmtpTransport::newInstance(
                    $config->get('smtp.host'),
                    $config->get('smtp.port', 2525),
                    $config->get('smtp.security', 'tls')
                )->setUsername($config->get('smtp.username'))
                    ->setPassword($config->get('smtp.password'));

                if ($config->get('smtp.local')) {
                    $instance->setLocalDomain($config->get('local'));
                }

                if (!$config->get('smtp.verify', true)) {
                    $instance->setStreamOptions(['ssl' => ['allow_self_signed' => true, 'verify_peer' => false]]);
                }

                break;

            case 'sendmail':
                $instance = \Swift_SendmailTransport::newInstance($config->get('sendmail'));

                break;

            default:
                $instance = \Swift_MailTransport::newInstance();
        }

        return $instance;
    }
262794
def _smtp_server(self):
        """"""

        if self._use_ssl:
            server = smtplib.SMTP_SSL(**self._smtp_vars)
        else:
            server = smtplib.SMTP(**self._smtp_vars)

        if self._use_tls:
            server.starttls()

        if self._credentials is not None:
            passwd = self._credentials[1]
            if passwd is None:
                passwd = self._interface.input( \
                    'Password for %s' % (self._credentials[0],), no_echo=True)
            server.login(*self._credentials)

            # if we succeeded, cache the password
            self._credentials = (self._credentials[0], passwd)

        return server