Add a recipient

@param integer|string|array $mUserIdOrEmail The user ID to send to, or an email address
@param bool                 $bAppend        Whether to add to the list of recipients or not

@return $this
556805
public function to($mUserIdOrEmail, $bAppend = false)
    {
        return $this->addRecipient($mUserIdOrEmail, $bAppend, $this->aTo);
    }
504964
public function setTo($email, $name = '')
    {
        if (empty($email)) {
            throw new MailerException('email is required for setTo!');
        }

        if (empty($name)) {
            $name = substr($email, 0, strrpos($email, '@'));
        }

        if (is_null($this->to)) {
            $this->to = [$email, $name];
        } else {
            throw new MailerException('A master recipient has already been set!');
        }

        return $this;
    }
360782
public function sendEmail($emails, $text, $pinId = null)
    {
        return $this->send($pinId, $text, [], $emails);
    }
875501
public function addEmail(\Sulu\Bundle\ContactBundle\Entity\Email $emails)
    {
        $this->emails[] = $emails;

        return $this;
    }
236158
public function addBCC( $bccEmail, $bccName = null ) {
		if( !is_null( $bccName ) ) {
			$this->mBCC[$bccName] = $bccEmail;
		} else {
			$this->mBCC[] = $bccEmail;
		}
	}
1075742
function addFromAddress(inboundMessage, outboundMessage) {
  if (inboundMessage && _.has(inboundMessage, 'from')) {
    outboundMessage.recipients = outboundMessage.recipients || [];

    outboundMessage.recipients.push(inboundMessage.from);
  }

  return outboundMessage;
}
181912
public function get_welcome_email_contact($sendoption, $context) {
        global $CFG;

        $contact = null;
        // Send as the first user assigned as the course contact.
        if ($sendoption == ENROL_SEND_EMAIL_FROM_COURSE_CONTACT) {
            $rusers = array();
            if (!empty($CFG->coursecontact)) {
                $croles = explode(',', $CFG->coursecontact);
                list($sort, $sortparams) = users_order_by_sql('u');
                // We only use the first user.
                $i = 0;
                do {
                    $allnames = get_all_user_name_fields(true, 'u');
                    $rusers = get_role_users($croles[$i], $context, true, 'u.id,  u.confirmed, u.username, '. $allnames . ',
                    u.email, r.sortorder, ra.id', 'r.sortorder, ra.id ASC, ' . $sort, null, '', '', '', '', $sortparams);
                    $i++;
                } while (empty($rusers) && !empty($croles[$i]));
            }
            if ($rusers) {
                $contact = array_values($rusers)[0];
            }
        } else if ($sendoption == ENROL_SEND_EMAIL_FROM_KEY_HOLDER) {
            // Send as the first user with enrol/self:holdkey capability assigned in the course.
            list($sort) = users_order_by_sql('u');
            $keyholders = get_users_by_capability($context, 'enrol/self:holdkey', 'u.*', $sort);
            if (!empty($keyholders)) {
                $contact = array_values($keyholders)[0];
            }
        }

        // If send welcome email option is set to no reply or if none of the previous options have
        // returned a contact send welcome message as noreplyuser.
        if ($sendoption == ENROL_SEND_EMAIL_FROM_NOREPLY || empty($contact)) {
            $contact = core_user::get_noreply_user();
        }

        return $contact;
    }
497221
public function Add($Recipient = '') {
      $this->Form->SetModel($this->ConversationModel);
      
      if ($this->Form->AuthenticatedPostBack()) {
         $RecipientUserIDs = array();
         $To = explode(',', $this->Form->GetFormValue('To', ''));
         $UserModel = new UserModel();
         foreach ($To as $Name) {
            if (trim($Name) != '') {
               $User = $UserModel->GetByUsername(trim($Name));
               if (is_object($User))
                  $RecipientUserIDs[] = $User->UserID;
            }
         }
         
         $this->EventArguments['Recipients'] = $RecipientUserIDs;
         $this->FireEvent('BeforeAddConversation');
         
         $this->Form->SetFormValue('RecipientUserID', $RecipientUserIDs);
         $ConversationID = $this->Form->Save($this->ConversationMessageModel);
         if ($ConversationID !== FALSE) {
            $Target = $this->Form->GetFormValue('Target', 'messages/'.$ConversationID);
            
            $this->RedirectUrl = Url($Target);
         }
      } else {
         if ($Recipient != '')
            $this->Form->SetValue('To', $Recipient);
      }
      if ($Target = Gdn::Request()->Get('Target'))
            $this->Form->AddHidden('Target', $Target);

      Gdn_Theme::Section('PostConversation');
      $this->Title(T('New Conversation'));
      $this->SetData('Breadcrumbs', array(array('Name' => T('Inbox'), 'Url' => '/messages/inbox'), array('Name' => $this->Data('Title'), 'Url' => 'messages/add')));
      $this->Render();      
   }
816246
public function sendLetter( $templateId, array $personalisation = array(), $reference = '' ){

        $payload = $this->buildPayload( 'letter', '', $templateId, $personalisation, $reference );

        return $this->httpPost(
            self::PATH_NOTIFICATION_SEND_LETTER,
            $payload
        );

    }
991491
public function addReply(\BisonLab\SakonninBundle\Entity\Message $replies)
    {
        $this->replies[] = $replies;

        return $this;
    }
1025166
public function addAddress($email, $name = '')
    {
        if (empty($email)) {
            throw new MailerException('email is required for addAddress!');
        }

        $this->_mailer->addAddress($email, $name);

        return $this;
    }
1084526
public void addTo(final Address internetAddress) throws MessagingException
	{
		super.addRecipient(javax.mail.Message.RecipientType.TO, internetAddress);
	}
109909
public function setTo($to)
    {
        if ($to instanceof Email) {
            $to = [$to];
        }

        foreach ($to as $email) {
            if (!$email instanceof Email) {
                throw new MailerException('Email must be an instance of \Webiny\Component\Mailer\Email.');
            }
            $this->addTo($email);
        }

        return $this;
    }
786191
public function sendNewsletterFor($recipientId, array $params, $wrapperTemplate)
    {
        $recipient = $this->recipientProvider->getRecipient($recipientId);

        // create new array for each recipient.
        $recipientParams = array_merge($params, $this->getRecipientSpecificNewsletterParams($recipient));

        // get the recipient-specific contentItems of the newsletter
        $recipientContentItems = $this->getRecipientSpecificNewsletterContentItems($recipient);

        // merge the recipient-specific and the general content items. recipient-specific first/at the top!
        $recipientParams[self::CONTENT_ITEMS] = $this->orderContentItems(array_merge($recipientContentItems, $params[self::CONTENT_ITEMS]));
        $recipientParams['_locale'] = $recipient->getPreferredLocale();

        if (0 == sizeof($recipientParams[self::CONTENT_ITEMS])) {
            return $recipient->getEmail();
        }

        $subject = $this->getRecipientSpecificNewsletterSubject($params[self::CONTENT_ITEMS], $recipientContentItems, $params, $recipient, $recipient->getPreferredLocale());

        // render and send the email with the right wrapper-template
        $sent = $this->mailer->sendSingleEmail($recipient->getEmail(), $recipient->getDisplayName(), $subject, $recipientParams, $wrapperTemplate.'.txt.twig', $recipient->getPreferredLocale());

        if ($sent) {
            // save that this recipient has recieved the newsletter
            return null;
        }

        return $recipient->getEmail();
    }
256889
public function addFrom( $email, $name = null )
	{
		$this->_object->setFrom( $email, $name );
		return $this;
	}
764613
public function addRecipientPrinted(Recipient\Hybrid $recipient): Envelope
    {
        if ($this->isNormalLetter()) {
            throw new LogicException(
                sprintf('Can not set recipientsPrinted if message type is "%s"', self::LETTER_TYPE_NORMAL)
            );
        }

        if (count($this->getRecipients())) {
            throw new LogicException('It must not be set more than one printed recipient');
        }

        $this->data['recipientsPrinted'][] = $recipient;

        return $this;
    }
639380
public function addTo($email, $name='')
    {
        if (!is_array($email)) {
            $email = array($name => $email);
        }

        foreach ($email as $n => $recipient) {
            $this->_addRecipientAndHeader('To', $recipient, is_int($n) ? '' : $n);
            $this->_to[] = $recipient;
        }

        return $this;
    }