For example, you may predefine in 'messageConfig' default contents of 'From' field:
~~~
'mail' => [
...
'messageConfig'    => [
'from' => ['noreply@example.com' => 'My Example Site']
],
...
];
~~~
556080
public function init()
    {
        $this->adapter = new Adapter();

        if (!is_array($this->config)) {
            throw new InvalidConfigException('Mailer config should be set in terms of array');
        }

        if (!empty($this->config)) {
            //special handling of language
            $this->adapter->setLanguage(ArrayHelper::remove($this->config, 'language', Yii::$app->language));

            //special handling of callback (see definition of \PHPMailer::$action_function)
            $this->adapter->setCallback(ArrayHelper::remove($this->config, 'callback', 'zyx\phpmailer\Mailer::processResult'));

            //special hadling of charset. Note: PHPMailer in [[createBody()]] overrides charset and sets 'us-ascii' if no 8-bit chars are found!
            $this->adapter->setCharset(!empty($this->messageConfig['charset']) ? $this->messageConfig['charset'] : ArrayHelper::remove($this->config, 'charset', Yii::$app->charset));

            //special handling of our 'global' isHTML switch
            $this->adapter->isHTML((bool)ArrayHelper::remove($this->config, 'ishtml', false));

            //set other properties, compliant with PHPMailer's configuration public properties
            foreach (get_object_vars($this->adapter) as $prop => $value) {
                $key = strtolower($prop);
                if (array_key_exists($key, $this->config)) {
                    $this->adapter->$prop = $this->config[$key];
                }
            }
        }

        //Set current message date initially - a workaround for MessageDate bug in PHPMailer <= 5.2.7
        //see https://github.com/PHPMailer/PHPMailer/pull/227

        if (version_compare($this->adapter->getVersion(), '5.2.7', '<=') && $this->adapter->getMessageDate() == '') {
            $this->adapter->setMessageDate();
        }

    }
437609
function (fieldDefinition, fieldName) {
    const fieldType = propertyHelper.getFieldType(fieldDefinition);

    let checks;
    if (fieldType === 'string' || fieldType === 'email') {
      // first create the string checks
      checks = createChecksString(fieldDefinition, fieldName);
    }

    if (fieldType === 'email') {
      // for email an additional check will be added
      checks.push(createCheckEmail(fieldDefinition, fieldName));
    }

    // This must be the last one, because the email check will delete the value from the content
    if (fieldType === 'string' || fieldType === 'email') {
      const defaultValueCheck = createCheckDefaultValue(fieldDefinition, fieldName);
      if (defaultValueCheck !== undefined) {
        checks.push(defaultValueCheck);
      }
    }
    return checks;
  }
343084
public MailMessage defaultFrom(String email, String name) {

		if (StringUtils.isNullOrEmptyTrimmed(fromEmail)) {
			from(email, name);
		}

		if (!StringUtils.isNullOrEmptyTrimmed(email) &&
		    StringUtils.equals(fromEmail, email.trim(), true) &&
		    StringUtils.isNullOrEmptyTrimmed(fromName)) {
			from(email, name);
		}

		return this;
	}
250800
public MailContent text(String s) {
        html.a(escapeXml(s));
        text.a(s);
        return this;
    }
531594
function(apiKey, contactList, fromAddress,
        toAddress, ccAddresses, bccAddresses, contentType, subject, htmlBody,
        textBody, _templateId) {}
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,
        )
75139
def recipients(preferences, message, valid_paths, config):
    

    rule_cache = dict()
    results = defaultdict(list)
    notified = set()

    for preference in preferences:
        user = preference['user']
        context = preference['context']
        if (user['openid'], context['name']) in notified:
            continue

        for filter in preference['filters']:
            if matches(filter, message, valid_paths, rule_cache, config):
                for detail_value in preference['detail_values']:
                    results[context['name']].append({
                        'user': user['openid'],
                        context['detail_name']: detail_value,
                        'filter_name': filter['name'],
                        'filter_id': filter['id'],
                        'filter_oneshot': filter['oneshot'],
                        'markup_messages': preference['markup_messages'],
                        'triggered_by_links': preference['triggered_by_links'],
                        'shorten_links': preference['shorten_links'],
                        'verbose': preference['verbose'],
                    })
                notified.add((user['openid'], context['name']))
                break

    return results
1271306
function formatAddressField($message, $field)
    {
        $headers = $message->getHeaders();

        if (!$headers->has($field)) {
            return null;
        }

        $mailboxes = $headers->get($field)->getFieldBodyModel();

        $strings = [];
        foreach ($mailboxes as $email => $name) {
            $mailboxStr = $email;
            if (null !== $name) {
                $mailboxStr = $name . ' <' . $mailboxStr . '>';
            }
            $strings[] = $mailboxStr;
        }
        return implode(', ', $strings);
    }
947693
def from_email(self, value):
        
        if isinstance(value, str):
            value = From(value, None)
        if isinstance(value, tuple):
            value = From(value[0], value[1])
        self._from_email = value
156270
protected function setConfigReplyTo()
    {
        $address = $this->config->get('mailgun.reply_to.address');
        $name = $this->config->get('mailgun.reply_to.name');
        if ($address) {
            $name = $name ? ['full_name' => $name] : null;
            $this->messageBuilder->setReplyToAddress($address, $name);
        }
    }
842276
def contrib_email(contrib_tag):
    
    email = []
    for email_tag in extract_nodes(contrib_tag, "email"):
        if email_tag.parent.name != "aff":
            email.append(email_tag.text)
    return email if len(email) > 0 else None
691232
def fields
      [
        ["Handle", :handle, proc { |v| v.to_hash }, :required],
        ["Id", :handle, proc { |v| v.id }, :required],
        ["DebtorHandle", :debtor, proc { |v| v.handle.to_hash }],
        ["Name", :name, nil, :required],
        ["Number", :number],
        ["TelephoneNumber", :telephone_number],
        ["Email", :email],
        ["Comments", :comments],
        ["ExternalId", :external_id],
        ["IsToReceiveEmailCopyOfOrder", :is_to_receive_email_copy_of_order, proc { |v| v || false }, :required],
        ["IsToReceiveEmailCopyOfInvoice", :is_to_receive_email_copy_of_invoice, proc { |v| v || false }, :required]
      ]
    end
614756
public static void configureMail(CmsMailHost host, Email mail) {

        // set the host to the default mail host
        mail.setHostName(host.getHostname());
        mail.setSmtpPort(host.getPort());

        // check if username and password are provided
        String userName = host.getUsername();
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(userName)) {
            // authentication needed, set user name and password
            mail.setAuthentication(userName, host.getPassword());
        }
        String security = host.getSecurity() != null ? host.getSecurity().trim() : null;
        if (SECURITY_SSL.equalsIgnoreCase(security)) {
            mail.setSslSmtpPort("" + host.getPort());
            mail.setSSLOnConnect(true);
        } else if (SECURITY_STARTTLS.equalsIgnoreCase(security)) {
            mail.setStartTLSEnabled(true);
        }

        try {
            // set default mail from address
            mail.setFrom(OpenCms.getSystemInfo().getMailSettings().getMailFromDefault());
        } catch (EmailException e) {
            // default email address is not valid, log error
            LOG.error(Messages.get().getBundle().key(Messages.LOG_INVALID_SENDER_ADDRESS_0), e);
        }
    }
28423
def __parameter_default(self, field):
    
    if field.default:
      if isinstance(field, messages.EnumField):
        return field.default.name
      else:
        return field.default
92472
def options(self):
        
        config = self._config
        o = {}
        o.update(self._default_smtp_options)
        o.update(self._default_message_options)
        o.update(self._default_backend_options)
        o.update(get_namespace(config, 'EMAIL_', valid_keys=o.keys()))
        o['port'] = int(o['port'])
        o['timeout'] = float(o['timeout'])
        return o
15828
function getOverriddenEmail(email: string): string {
  if (!cfg.email.devEmail) {
    throw new Error("Email failed to send: cfg.email.devEmail is not set");
  }
  const devEmailParts = cfg.email.devEmail.split("@");
  return `${devEmailParts[0]}+${email.replace("@", ".at.")}@${
    devEmailParts[1]
  }`;
}
134315
function parseDefaultSettings() {
    var defaultSettingsInCategories = require('../data/schema/').defaultSettings,
        defaultSettingsFlattened = {},
        dynamicDefault = {
            db_hash: uuid.v4(),
            public_hash: crypto.randomBytes(15).toString('hex'),
            // @TODO: session_secret would ideally be named "admin_session_secret"
            session_secret: crypto.randomBytes(32).toString('hex'),
            members_session_secret: crypto.randomBytes(32).toString('hex'),
            theme_session_secret: crypto.randomBytes(32).toString('hex')
        };

    const membersKeypair = keypair({
        bits: 1024
    });

    dynamicDefault.members_public_key = membersKeypair.public;
    dynamicDefault.members_private_key = membersKeypair.private;

    _.each(defaultSettingsInCategories, function each(settings, categoryName) {
        _.each(settings, function each(setting, settingName) {
            setting.type = categoryName;
            setting.key = settingName;
            if (dynamicDefault[setting.key]) {
                setting.defaultValue = dynamicDefault[setting.key];
            }

            defaultSettingsFlattened[settingName] = setting;
        });
    });

    return defaultSettingsFlattened;
}