Sends a Email to user.email.

    Passes silently without sending in test environment
778695
def send_email_with_callback_token(user, email_token, **kwargs):
    

    try:
        if api_settings.PASSWORDLESS_EMAIL_NOREPLY_ADDRESS:
            # Make sure we have a sending address before sending.

            # Get email subject and message
            email_subject = kwargs.get('email_subject',
                                       api_settings.PASSWORDLESS_EMAIL_SUBJECT)
            email_plaintext = kwargs.get('email_plaintext',
                                         api_settings.PASSWORDLESS_EMAIL_PLAINTEXT_MESSAGE)
            email_html = kwargs.get('email_html',
                                    api_settings.PASSWORDLESS_EMAIL_TOKEN_HTML_TEMPLATE_NAME)

            # Inject context if user specifies.
            context = inject_template_context({'callback_token': email_token.key, })
            html_message = loader.render_to_string(email_html, context,)
            send_mail(
                email_subject,
                email_plaintext % email_token.key,
                api_settings.PASSWORDLESS_EMAIL_NOREPLY_ADDRESS,
                [getattr(user, api_settings.PASSWORDLESS_USER_EMAIL_FIELD_NAME)],
                fail_silently=False,
                html_message=html_message,)

        else:
            logger.debug("Failed to send token email. Missing PASSWORDLESS_EMAIL_NOREPLY_ADDRESS.")
            return False
        return True

    except Exception as e:
        logger.debug("Failed to send token email to user: %d."
                  "Possibly no email on user object. Email entered was %s" %
                  (user.id, getattr(user, api_settings.PASSWORDLESS_USER_EMAIL_FIELD_NAME)))
        logger.debug(e)
        return False
339502
public void setEmail(String email) {
        SystemAssert.requireArgument(email != null && !email.isEmpty(), "Email cannot be null or empty.");
        this.email = email;
    }
936591
def render_or_send(func, message):
    """"""
    if request.endpoint != func.func_name:
        mail.send(message)

    if (current_user.is_authenticated() and current_user.superuser):
        return render_template('debug_email.html', message=message)
208314
def run_send_all(*args):
    '''
    
    '''
    for user_rec in MUser.query_all():
        email_add = user_rec.user_email
        send_mail([email_add],
                  "{0}|{1}".format(SMTP_CFG['name'], email_cfg['title']),
                  email_cfg['content'])
682359
def send(self):
        
        # if it has already been sent don't send again
        if self.status is OUTWARD_STATUS.get('sent'):
            return False
        # determine recipients
        recipients = self.get_recipients()
        # init empty list that will contain django's email objects
        emails = []

        # prepare text plain if necessary
        if OUTWARD_HTML:
            # store plain text in var
            html_content = self.message
            # set EmailClass to EmailMultiAlternatives
            EmailClass = EmailMultiAlternatives
        else:
            EmailClass = EmailMessage

        # default message is plain text
        message = strip_tags(self.message)

        # loop over recipients and fill "emails" list
        for recipient in recipients:
            msg = EmailClass(
                # subject
                self.subject,
                # message
                message,
                # from
                settings.DEFAULT_FROM_EMAIL,
                # to
                [recipient],
            )
            if OUTWARD_HTML:
                msg.attach_alternative(html_content, "text/html")
            # prepare email object
            emails.append(msg)

        # try sending email
        try:
            # counter will count how many emails have been sent
            counter = 0
            for email in emails:
                # if step reached
                if counter == OUTWARD_STEP:
                    # reset counter
                    counter = 0
                    # sleep
                    time.sleep(OUTWARD_DELAY)
                # send email
                email.send()
                # increase counter
                counter += 1
        # if error (connection refused, SMTP down)
        except socket.error as e:
            # log the error
            from logging import error
            error('nodeshot.core.mailing.models.outward.send(): %s' % e)
            # set status of the instance as "error"
            self.status = OUTWARD_STATUS.get('error')
        # change status
        self.status = OUTWARD_STATUS.get('sent')
        # save
        self.save()
1324011
function(email) {
      var user = this.getUser();
      if (user) {
        return this._q.when(user.updateEmail(email));
      } else {
        return this._q.reject("Cannot update email since there is no logged in user.");
      }
    }
1270134
public void send(Email email) throws EmailException {
    synchronized (this) {
      EmailConnection connection = openConnection();
      connection.connect();
      
      connection.send(email);
      
      connection.close();
    }
  }
435252
def send(self, email=None):
        
        if email is None and self.send_as_one:
            self.smtp.send_message(
                self.multipart, self.config['EMAIL'], self.addresses)
        elif email is not None and self.send_as_one is False:
            self.smtp.send_message(
                self.multipart, self.config['EMAIL'], email)
        self.multipart = MIMEMultipart('alternative')
902248
def send_mail_worker(config, mail, event):
    """"""
    log = ""

    try:
        if config.get('ssl', True):
            server = SMTP_SSL(config['server'], port=config['port'], timeout=30)
        else:
            server = SMTP(config['server'], port=config['port'], timeout=30)

        if config['tls']:
            log += 'Starting TLS\n'
            server.starttls()

        if config['username'] != '':
            log += 'Logging in with ' + str(config['username']) + "\n"
            server.login(config['username'], config['password'])
        else:
            log += 'No username, trying anonymous access\n'

        log += 'Sending Mail\n'
        response_send = server.send_message(mail)
        server.quit()

    except timeout as e:
        log += 'Could not send email: ' + str(e) + "\n"
        return False, log, event

    log += 'Server response:' + str(response_send)
    return True, log, event
598397
public function index()
    {
        if (!userHasPermission('admin:email:utilities:sendTest')) {
            unauthorised();
        }

        // --------------------------------------------------------------------------

        //  Page Title
        $this->data['page']->title = 'Send a Test Email';

        // --------------------------------------------------------------------------

        $oInput = Factory::service('Input');
        if ($oInput->post()) {

            //  Form validation and update
            $oFormValidation = Factory::service('FormValidation');

            //  Define rules
            $oFormValidation->set_rules('recipient', '', 'required|valid_email');

            //  Set Messages
            $oFormValidation->set_message('required', lang('fv_required'));
            $oFormValidation->set_message('valid_email', lang('fv_valid_email'));

            //  Execute
            if ($oFormValidation->run()) {

                //  Prepare data
                $oNow   = Factory::factory('DateTime');
                $oEmail = (object) [
                    'type'     => 'test_email',
                    'to_email' => $oInput->post('recipient', true),
                    'data'     => [
                        'sentAt' => $oNow->format('Y-m-d H:i:s'),
                    ],
                ];

                //  Send the email
                $oEmailer = Factory::service('Emailer', 'nails/module-email');
                if ($oEmailer->send($oEmail)) {

                    $this->data['success'] = '<strong>Done!</strong> Test email successfully sent to <strong>';
                    $this->data['success'] .= $oEmail->to_email . '</strong> at ' . toUserDatetime();

                } else {

                    echo '<h1>Sending Failed, debugging data below:</h1>';
                    echo $oEmailer->print_debugger();
                    return;
                }
            }
        }

        // --------------------------------------------------------------------------

        //  Load views
        Helper::loadView('index');
    }
785253
def sendmail(array):
    
    username = 'root@robin8.io'
    FROM = username
    TO = [array["to"]]
    SUBJECT = array["subject"]
    # check on correct data in optional
    if type(array["optional"]) == str and array["optional"]:
        TEXT = array["optional"]
    else:
        return "Error: missed argument"
    # make template
    message = """From: %s\nTo: %s\nSubject: %s\n\n%s""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
    try:
        server = smtplib.SMTP('localhost')
        logging.info(server)
        #server.ehlo()
        #server.starttls()
        # authorizing user, must setup your account
        #server.login(username, password)
        # send mail
        server.sendmail(FROM, TO, message)
        server.quit()
        logging.info(message)
        return "Success"
    except:
        return "Error"
924978
def send_mail(subject, body, smtp_server, user, password, from_addr, to_addrs):
    ''' 
    '''
    logging.info('Send status E-Mail (' + subject + ')')
    content = string.join((
        "From: %s" % from_addr,
        "To: %s" % ','.join(to_addrs),  # comma separated according to RFC822
        "Subject: %s" % subject,
        "",
        body),
        "\r\n")
    server = smtplib.SMTP_SSL(smtp_server)
    server.login(user, password)
    server.sendmail(from_addr, to_addrs, content)
    server.quit()
612610
function (rawEmail, callback) {
        if (!isPythonAvailable) {
            return callback(null, false);
        }

        var verifyDkimPath = path.join(__dirname, '../python/verifydkim.py');
        var verifyDkim = child_process.spawn('python', [verifyDkimPath]);

        verifyDkim.stdout.on('data', function (data) {
            logger.verbose(data.toString());
        });

        verifyDkim.on('close', function (code) {
            logger.verbose('closed with return code ' + code);
            /* Convert return code to appropriate boolean. */
            return callback(null, !!!code);
        });

        verifyDkim.stdin.write(rawEmail);
        verifyDkim.stdin.end();
    }
65383
def send_mail_worker(config, mail, event):
    """"""
    log = ""

    try:
        if config.mail_ssl:
            server = SMTP_SSL(config.mail_server, port=config.mail_server_port, timeout=30)
        else:
            server = SMTP(config.mail_server, port=config.mail_server_port, timeout=30)

        if config.mail_tls:
            log += 'Starting TLS\n'
            server.starttls()

        if config.mail_username != '':
            log += 'Logging in with ' + str(config.mail_username) + "\n"
            server.login(config.mail_username, config.mail_password)
        else:
            log += 'No username, trying anonymous access\n'

        log += 'Sending Mail\n'
        response_send = server.send_message(mail)
        server.quit()

    except timeout as e:
        log += 'Could not send email to enrollee, mailserver timeout: ' + str(e) + "\n"
        return False, log, event

    log += 'Server response:' + str(response_send)
    return True, log, event
997748
def send_email(self, template, **kwargs):
        
        user_data = {
            "id": self.id,
            "username": self.username,
            "name": self.name,
            "first_name": self.first_name,
            "last_name": self.last_name,
            "email": self.email
        }
        kwargs.pop("user", None)
        send_mail(to=self.email, template=template, user=user_data, **kwargs)
1083244
def send(
            self):
        
        self.log.debug('starting the ``send`` method')

        if self.urlOrPath.split(".")[-1] == "docx":
            if self.title:
                pathToMobi = self.outputDirectory + "/" + self.title + ".docx"
            else:
                pathToMobi = self.outputDirectory + "/" + \
                    os.path.basename(self.urlOrPath)
            shutil.copyfile(self.urlOrPath, pathToMobi)
        else:
            pathToMobi = self.get()
            if not pathToMobi:
                return 404

        # create MIME message

        msg = MIMEMultipart()
        msg['From'] = self.settings["email"]["user_email"]
        msg['To'] = ", ".join(self.settings["email"]["kindle_emails"])
        msg['Subject'] = 'Polyglot to Kindle'
        text = 'This email has been automatically sent by polyglot'
        msg.attach(MIMEText(text))

        basename = os.path.basename(pathToMobi)
        print "Sending the book `%(pathToMobi)s` to Kindle device(s)" % locals()
        msg.attach(self.get_attachment(pathToMobi))

        # convert MIME message to string
        fp = StringIO()
        gen = Generator(fp, mangle_from_=False)
        gen.flatten(msg)
        msg = fp.getvalue()

        # send email
        try:
            mail_server = smtplib.SMTP_SSL(host=self.settings["email"]["smtp_server"],
                                           port=self.settings["email"]["smtp_port"])
            mail_server.login(self.settings["email"]["smtp_login"], self.settings[
                              "email"]["smtp_password"])
            mail_server.sendmail(self.settings["email"]["user_email"], ", ".join(self.settings[
                                 "email"]["kindle_emails"]), msg)
            mail_server.close()
        except smtplib.SMTPException:
            os.remove(pathToMobi)
            self.log.error(
                'Communication with your SMTP server failed. Maybe wrong connection details? Check exception details and your headjack settings file')
            return False

        os.remove(pathToMobi)

        self.log.debug('completed the ``send`` method')
        return True
900814
def send_registered_email(self, user, user_email, request_email_confirmation):
        """"""

        # Verify config settings
        if not self.user_manager.USER_ENABLE_EMAIL: return
        if not self.user_manager.USER_SEND_REGISTERED_EMAIL: return

        # The registered email is sent to a specific user_email.email or user.email
        email = user_email.email if user_email else user.email

        # Add a request to confirm email if needed
        if request_email_confirmation:
            # Generate a confirm_email_link
            token = self.user_manager.generate_token(user_email.id if user_email else user.id)
            confirm_email_link = url_for('user.confirm_email', token=token, _external=True)
        else:
            confirm_email_link = None

        # Render email from templates and send it via the configured EmailAdapter
        self._render_and_send_email(
            email,
            user,
            self.user_manager.USER_REGISTERED_EMAIL_TEMPLATE,
            confirm_email_link=confirm_email_link,
        )