Present the email headers
428994
def iteritems(self):
        """"""
        for n,v in self.msgobj.__dict__["_headers"]:
            yield n.lower(), v
        return
662785
public function index()
    {
        $oUri     = Factory::service('Uri');
        $oEmailer = Factory::service('Emailer', 'nails/module-email');
        $sRef     = $oUri->segment(3);
        $sGuid    = $oUri->segment(4);
        $sHash    = $oUri->segment(5);

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

        //  Fetch the email
        if (is_numeric($sRef)) {
            $oEmail = $oEmailer->getById($sRef);
        } else {
            $oEmail = $oEmailer->getByRef($sRef);
        }

        if (!$oEmail || !$oEmailer->validateHash($oEmail->ref, $sGuid, $sHash)) {
            show404();
        }

        if (Environment::is(Environment::ENV_DEV)) {

            $oAsset = Factory::service('Asset');
            $oAsset->load('debugger.min.css', 'nails/module-email');

            Factory::service('View')
                ->setData([
                    'oEmail' => $oEmail,
                ])
                ->load([
                    'structure/header/blank',
                    'email/view',
                    'structure/footer/blank',
                ]);

        } else {
            $oOutput = Factory::service('Output');
            $oOutput->set_output($oEmail->body->html);
        }
    }
191528
def _map_smtp_headers_to_api_parameters(self, email_message):
        
        api_data = []
        for smtp_key, api_transformer in six.iteritems(self._headers_map):
            data_to_transform = email_message.extra_headers.pop(smtp_key, None)
            if data_to_transform is not None:
                if isinstance(data_to_transform, (list, tuple)):
                    # map each value in the tuple/list
                    for data in data_to_transform:
                        api_data.append((api_transformer[0], api_transformer[1](data)))
                elif isinstance(data_to_transform, dict):
                    for data in six.iteritems(data_to_transform):
                        api_data.append(api_transformer(data))
                else:
                    # we only have one value
                    api_data.append((api_transformer[0], api_transformer[1](data_to_transform)))
        return api_data
777289
function(){
			var payload = { recipients: {} },
				invalid = [],
				promise = new Promise();
			for(var i=0, j=this.mails.length; i < j; i++){
				var data = this.mails[i],
					email = data.email;

					if(!data.template_id){
						invalid.push(data)
						data.error = "No template provided"
						continue;
					}

					if(typeof data.email === 'undefined'){
						invalid.push(data)
						data.error = "No email provided"
						continue;
					}


				delete data['email'];

				payload.recipients[email] = data
			}
			if(invalid.length > 0){
				promise.reject('invalid', invalid);
			}else{
				apostle.send(payload, promise);
			}
			return promise;
		}
708992
def render_mail(self, template_prefix, email, context):
        
        subject = render_to_string('{0}_subject.txt'.format(template_prefix),
                                   context)
        # remove superfluous line breaks
        subject = " ".join(subject.splitlines()).strip()
        subject = self.format_email_subject(subject)

        bodies = {}
        for ext in ['html', 'txt']:
            try:
                template_name = '{0}_message.{1}'.format(template_prefix, ext)
                bodies[ext] = render_to_string(template_name,
                                               context).strip()
            except TemplateDoesNotExist:
                if ext == 'txt' and not bodies:
                    # We need at least one body
                    raise
        if 'txt' in bodies:
            msg = EmailMultiAlternatives(subject,
                                         bodies['txt'],
                                         settings.DEFAULT_FROM_EMAIL,
                                         [email])
            if 'html' in bodies:
                msg.attach_alternative(bodies['html'], 'text/html')
        else:
            msg = EmailMessage(subject,
                               bodies['html'],
                               settings.DEFAULT_FROM_EMAIL,
                               [email])
            msg.content_subtype = 'html'  # Main content is now text/html
        return msg
488290
def message(self):
        
        return '\n'.join(
            [self.from_email, str(self.to), self.subject, self.body])
319849
def email(self, name, to, from_addr, subject, body, header, owner=None, **kwargs):
        
        return Email(self.tcex, name, to, from_addr, subject, body, header, owner=owner, **kwargs)
180872
def decode_message_headers(msg_headers):
    '''
    
    '''

    headers_to_decode = ['from', 'reply-to', 'subject', 'to']

    for item in headers_to_decode:
        return_list = []
        try:
            # decode the header
            decoded_header = pyzmail_decode_mail_header(msg_headers[item][0])
            # add the header to a list as we want to return a list
            return_list.append(decoded_header)
            # replace the item in the dict with a decoded version
            msg_headers[item] = return_list

        except KeyError:
            pass

    return msg_headers
107889
function(data) {
      var headers = {
        email: data.email,
        password: data.password,
        contentType: 'audio/wav'
      };

      var body = data.wav;

      return client.request('POST', 'enrollments', headers, body);
    }
993328
def header(self):
        '''
        
        '''
        self.config.display.format_strings(self.HEADER_FORMAT, self.RESULT_FORMAT)
        self.config.display.add_custom_header(self.VERBOSE_FORMAT, self.VERBOSE)

        if type(self.HEADER) == type([]):
            self.config.display.header(*self.HEADER, file_name=self.current_target_file_name)
        elif self.HEADER:
            self.config.display.header(self.HEADER, file_name=self.current_target_file_name)
1131181
def email_list(mail)
      [mail.to, mail.bcc, mail.cc].flatten.uniq.compact
    end
107438
def parse_email_headers(s)
		keys={}
		match = (s =~ /\A((\w[\w\s\_\-]+: .*\n)+)\s*\n/)
		if match != 0
			keys[:data] = s
		else
			keys[:data] = $'
			headers = $1
			headers.split("\n").each do |l| 
# Fails if there are other ':' characters.
#				k, v = l.split(':')
				k, v = l.split(':', 2)
				k, v = normalize_key_and_value(k, v)
				k = k.to_sym
#				puts "K = #{k}, V=#{v}"
				keys[k] = v
			end
		end
		keys
	end
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)
620129
def as_string(self):
        """"""
        if self.headers_only:
            self.msgobj = self._get_content()

        # We could just use msgobj.as_string() but this is more flexible... we might need it.
        from email.generator import Generator
        fp = StringIO()
        g = Generator(fp, maxheaderlen=60)
        g.flatten(self.msgobj)
        text = fp.getvalue()
        return text
944321
private static function headers() {
        if (empty(self::$config['httpHeaders'])) {
            return;
        }

        $response = self::$config['httpContext']->getResponse();
        $response->setHeaders(self::$config['httpHeaders']);
    }
391308
function create_header() {
      $header = array();
      $header[] = sprintf("Date: %s\r\n", $this->rfc_date());

      // To be created automatically by mail()
      if($this->Mailer != "mail")
         $header[] = $this->addr_append("To", $this->to);

      $header[] = sprintf("From: %s <%s>\r\n", $this->FromName, trim($this->From));
      if(count($this->cc) > 0)
         $header[] = $this->addr_append("Cc", $this->cc);

      // sendmail and mail() extract Bcc from the header before sending
      if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
         $header[] = $this->addr_append("Bcc", $this->bcc);

      if(count($this->ReplyTo) > 0)
         $header[] = $this->addr_append("Reply-to", $this->ReplyTo);

      // mail() sets the subject itself
      if($this->Mailer != "mail")
         $header[] = sprintf("Subject: %s\r\n", trim($this->Subject));

      $header[] = sprintf("X-Priority: %d\r\n", $this->Priority);
      $header[] = sprintf("X-Mailer: phpmailer [version %s]\r\n", $this->Version);
      $header[] = sprintf("Return-Path: %s\r\n", trim($this->From));

      // Add custom headers
      for($index = 0; $index < count($this->CustomHeader); $index++)
         $header[] = sprintf("%s\r\n", $this->CustomHeader[$index]);

      if($this->UseMSMailHeaders)
         $header[] = $this->AddMSMailHeaders();

      $header[] = "MIME-Version: 1.0\r\n";

      // Add all attachments
      if(count($this->attachment) > 0 || !empty($this->AltBody))
      {
         // Set message boundary
         $this->boundary = "_b" . md5(uniqid(time()));
         // Set message subboundary for multipart/alternative
         $this->subboundary = "_sb" . md5(uniqid(time()));

         $header[] = "Content-Type: Multipart/Mixed;\r\n";
         $header[] = sprintf(" boundary=\"Boundary-=%s\"\r\n\r\n", $this->boundary);
      }
      else
      {
         $header[] = sprintf("Content-Transfer-Encoding: %s\r\n", $this->Encoding);
         $header[] = sprintf("Content-Type: %s; charset = \"%s\"\r\n\r\n",
                             $this->ContentType, $this->CharSet);
      }

      return(join("", $header));
   }
1282244
function(template, options){
			var payload = { data: {}, template_id: template };

			// Add root attributes to the payload root
			for(var attr in rootAttributes){
				if(!rootAttributes.hasOwnProperty(attr)){
					continue;
				}
				if(typeof options[attr] === 'undefined'){
					continue;
				}
				var key = rootAttributes[attr],
					val = options[attr];
				payload[key] = val;
				delete options[attr];
			}

			// Add any left over attribtues to the data object
			for(attr in options){
				if(!options.hasOwnProperty(attr)){
					continue;
				}
				payload.data[attr] = options[attr]
			}

			// Add to the list of emails
			this.mails.push(payload);
		}