Funxtion for sending email though gmail
175434
def send_mail(subject, body, email_from, emails_to):
    
    msg = MIMEText(body)
    msg['Subject'] = subject
    msg['From'] = email_from
    msg['To'] = ", ".join(emails_to)
    s = smtplib.SMTP('smtp.gmail.com', 587)
    s.ehlo()  # for tls add this line
    s.starttls()  # for tls add this line
    s.ehlo()  # for tls add this line
    s.login(SMTP_USERNAME, SMTP_PASSWORD)
    s.sendmail(email_from, emails_to, msg.as_string())
    s.quit()
1316975
private void sendEmail(Message m, SendRawEmailRequest req)
            throws SendFailedException, MessagingException {

        Address[] sent = null;
        Address[] unsent = null;
        Address[] invalid = null;

        try {
            appendUserAgent(req, USER_AGENT);
            SendRawEmailResult resp = this.emailService.sendRawEmail(req);
            lastMessageId = resp.getMessageId();
            sent = m.getAllRecipients();
            unsent = new Address[0];
            invalid = new Address[0];
            super.notifyTransportListeners(TransportEvent.MESSAGE_DELIVERED,
                    sent, unsent, invalid, m);
        } catch (Exception e) {
            sent = new Address[0];
            unsent = m.getAllRecipients();
            invalid = new Address[0];
            super.notifyTransportListeners(
                    TransportEvent.MESSAGE_NOT_DELIVERED, sent, unsent,
                    invalid, m);
            throw new SendFailedException("Unable to send email", e, sent,
                    unsent, invalid);
        }
    }
280645
function sendAlertEmail(alertEmailData, cb) {
  var mongoAlert = alertEmailData.alert;
  var eventDetails = alertEmailData.eventDetails;
  var emailConfig = config.getConfig().email;
  var from = emailConfig ? emailConfig.alert_email_from : 'noreply@feedhenry.com';

  fs.readFile(ALERT_EMAIL_TEMPLATE, function(err, data) {
    if (err) {
      return cb({
        'error': 'Could not load email template from "' + ALERT_EMAIL_TEMPLATE + '": ' + err
      });
    }
    var emailBody = data.toString();
    emailBody = emailBody.replace(/%appName%/g, eventDetails.appName || "");
    emailBody = emailBody.replace(/%appGuid%/g, eventDetails.uid);
    emailBody = emailBody.replace(/%appUrl%/g, ' ');
    emailBody = emailBody.replace(/%alertName%/g, mongoAlert.alertName);
    emailBody = emailBody.replace(/%eventTimestamp%/g, eventDetails.timestamp);
    emailBody = emailBody.replace(/%updatedBy%/g, eventDetails.updatedBy);
    emailBody = emailBody.replace(/%eventMessage%/g, eventDetails.details.message);
    emailBody = emailBody.replace(/%eventCategory%/g, eventDetails.eventClass);
    emailBody = emailBody.replace(/%eventName%/g, eventDetails.eventType);
    emailBody = emailBody.replace(/%eventSeverity%/g, eventDetails.eventLevel);
    emailBody = emailBody.replace(/%eventDetails%/g, JSON.stringify(eventDetails.details));
    emailBody = emailBody.replace(/%providerName%/g, from);

    getTransport(emailConfig).sendMail({
      from: from,
      to: mongoAlert.emails,
      subject: 'Alert Name: ' + mongoAlert.alertName + ' - Cloud App (' + mongoAlert.uid + ')',
      html: emailBody
    }, cb);
  });
}
993867
def send_mail(subject, message_plain, message_html, email_from, email_to,
              custom_headers={}, attachments=()):
    
    if not message_plain and not message_html:
        raise ValueError(_("Either message_plain or message_html should be not None"))

    if not message_plain:
        message_plain = html2text(message_html)

    message = {}

    message['subject'] = subject
    message['body'] = message_plain
    message['from_email'] = email_from
    message['to'] = email_to
    if attachments:
        message['attachments'] = attachments
    if custom_headers:
        message['headers'] = custom_headers

    msg = EmailMultiAlternatives(**message)
    if message_html:
        msg.attach_alternative(message_html, "text/html")
    msg.send()
633373
def send(self, text, fmt):
        
        main_fmt, sub_fmt = fmt.split('/')
        if sub_fmt.lower() == "text":
            msg = MIMEText(text, "plain")
        elif sub_fmt.lower() == "html":
            msg = MIMEText(text, "html")
        else:
            raise ValueError("Unknown message format: {}".format(fmt))
        msg['Subject'] = self._subject
        msg['From'] = self._sender
        msg['To'] = ', '.join(self._recipients)
        if self._port is None:
            conn_kwargs = dict(host=self._server)
        else:
            conn_kwargs = dict(host=self._server, port=self._port)
        self._log.info("connect to email server {}".format(conn_kwargs))
        try:
            s = smtplib.SMTP(**conn_kwargs)
            #s.set_debuglevel(2)
            refused = s.sendmail(self._sender, self._recipients, msg.as_string())
            if refused:
                self._log.warn("Email to {:d} recipients was refused".format(len(refused)))
                for person, (code, msg) in refused.items():
                    self._log("Email to {p} was refused ({c}): {m}".format(p=person, c=code, m=msg))
            s.quit()
            n_recip = len(self._recipients)
        except Exception as err:
            self._log.error("connection to SMTP server failed: {}".format(err))
            n_recip = 0
        return n_recip
674669
public void setEmail(String email) {

        checkEmail(email);
        if (email != null) {
            email = email.trim();
        }
        m_email = email;
    }
66790
def send_email(self, msg, tag=None):
        
        try:
            return self._send_email(msg, tag)
        except:
            self.exceptions.append(straceback())
            return -2
409859
def set_email(self, email, _vars=None, lists=None, templates=None, verified=0, optout=None, send=None, send_vars=None):
        
        _vars = _vars or {}
        lists = lists or []
        templates = templates or []
        send_vars = send_vars or []
        data = {'email': email,
                'vars':  _vars.copy(),
                'lists': lists,
                'templates': templates,
                'verified': int(verified)}
        if optout is not None:
            data['optout'] = optout
        if send is not None:
            data['send'] = send
        if send_vars:
            data['send_vars'] = send_vars
        return self.api_post('email', data)
363153
def send_message
      # Read the user's password from the persistent hash
      stored_password = @sender_info.transaction { @sender_info[:password] }
      # Initialize the gmail SMTP connection and upgrade to SSL/TLS
      smtp = Net::SMTP.new('smtp.gmail.com', 587)
      smtp.enable_starttls
      # Open SMTP connection, send message, close the connection
      smtp.start('gmail.com', @stored_from_address, stored_password, :login) do
        smtp.send_message(@msg, @_stored_from_address, @to_address)
      end
    end
1238964
function send_mail(opts) {
	var Q = require('q');
	var nodemailer = require("nodemailer");

	var smtpTransport = nodemailer.createTransport("SMTP", config.smtp);
	
	// setup e-mail data with unicode symbols
	var mailOptions = {
		from: opts.from,
		to: opts.to,
		subject: opts.subject,
		text: opts.text,
		html: opts.html
	};
	
	// send mail with defined transport object
	var defer = Q.defer();
	try {
		util.debug('Calling smtpTransport.sendMail()...');
		smtpTransport.sendMail(mailOptions, function(error, response){
			util.debug('End of smtpTransport.sendMail()');
			if(error){
				defer.reject(error);
				return;
			}
			defer.resolve(response);
		});
	} catch(err) {
		defer.reject(err);
	}
	return defer.promise.fin(function() { smtpTransport.close(); });
}
1286161
def deliver(self, message, to):
        
        # Send the message via local SMTP server.
        s = smtplib.SMTP(self.host, self.port)
        # sendmail function takes 3 arguments: sender's address, recipient's address
        # and message to send - here it is sent as one string.
        s.sendmail(message['From'], to, message.as_string())
        s.quit()
        return
902827
def _send_email(name, email):
    ""
    config = __salt__['config.option']('splunk')
    email_object = config.get('email')
    if email_object:
        cc = email_object.get('cc')
        subject = email_object.get('subject')
        message = email_object.get('message').format(name, name, _generate_password(email), name)

        try:
            mail_process = subprocess.Popen(['mail', '-s', subject, '-c', cc, email], stdin=subprocess.PIPE)
        except Exception as e:
            log.error("unable to send email to %s: %s", email, e)

        mail_process.communicate(message)

        log.info("sent account creation email to %s", email)
547656
def get_sender_gmail
      puts "Enter your gmail address:"
      while @from_address = gets.chomp
        catch :badfrom do
          if ValidateEmail.validate(@from_address) == true
            puts "Is your email address #{@from_address}? [y/n]:"
            while address_confirmation = gets.chomp
              case address_confirmation
              when 'y'
                return
              else
                puts "Please re-enter your gmail address:"
                throw :badfrom
              end
            end
          else
            puts "Email invalid! Please enter a valid email address:"
          end
        end
      end
    end
743289
def send_email(subject, message, sender, recipients, image_png=None):
    
    notifiers = {
        'ses': send_email_ses,
        'sendgrid': send_email_sendgrid,
        'smtp': send_email_smtp,
        'sns': send_email_sns,
    }

    subject = _prefix(subject)
    if not recipients or recipients == (None,):
        return

    if _email_disabled_reason():
        logger.info("Not sending email to %r because %s",
                    recipients, _email_disabled_reason())
        return

    # Clean the recipients lists to allow multiple email addresses, comma
    # separated in luigi.cfg
    recipients_tmp = []
    for r in recipients:
        recipients_tmp.extend([a.strip() for a in r.split(',') if a.strip()])

    # Replace original recipients with the clean list
    recipients = recipients_tmp

    logger.info("Sending email to %r", recipients)

    # Get appropriate sender and call it to send the notification
    email_sender = notifiers[email().method]
    email_sender(sender, subject, message, recipients, image_png)
1047157
def send_mail(subject, message, recipient_list, from_email=None,
              fail_silently=False, auth_user=None, auth_password=None,
              connection=None, **kwargs):
    
    connection = connection or get_connection(
        username=auth_user,
        password=auth_password,
        fail_silently=fail_silently,
    )
    mail_message = EmailMessage(subject, message, from_email, recipient_list,
                                **kwargs)

    return connection.send_messages([mail_message])
557253
def sendEmail(self, subject, body, toAddress=False):
        

        if not toAddress:
            toAddress = self.toAddress
        toAddress = toAddress.split(';')

        message = MIMEText(body)
        message['Subject'] = subject
        message['From'] = self.fromAddress
        message['To'] = ','.join(toAddress)

        if not self.testing:
            s = SMTP(self.server, self.port)

            s.sendmail(self.fromAddress, toAddress, message.as_string())
            s.quit()

            print('email sent')
        else:
            print('***Begin Test Email Message***')
            print(message)
            print('***End Test Email Message***')
168808
def Email(
        self,
        From,
        To,
        Cc=None,
        Bcc=None,
        Subject=None,
        Tag=None,
        HtmlBody=None,
        TextBody=None,
        Metadata=None,
        ReplyTo=None,
        Headers=None,
        TrackOpens=None,
        TrackLinks="None",
        Attachments=None,
    ):
        
        return Email(
            manager=self,
            From=From,
            To=To,
            Cc=Cc,
            Bcc=Bcc,
            Subject=Subject,
            Tag=Tag,
            HtmlBody=HtmlBody,
            TextBody=TextBody,
            Metadata=Metadata,
            ReplyTo=ReplyTo,
            Headers=Headers,
            TrackOpens=TrackOpens,
            TrackLinks=TrackLinks,
            Attachments=Attachments,
        )