luya\components\Mail::address PHP Method

address() public method

Add a single address with optional name
public address ( string $email, string $name = null ) : Mail
$email string The email address e.g. [email protected]
$name string The name for the address e.g. John Doe
return Mail
    public function address($email, $name = null)
    {
        $this->getMailer()->addAddress($email, empty($name) ? $email : $name);
        return $this;
    }

Usage Example

Beispiel #1
0
 public function testAdresses()
 {
     $mail = new Mail();
     $mail->address('*****@*****.**');
     $mail->address('*****@*****.**', 'John Doe');
     $mail->adresses(['*****@*****.**', 'Jane Doe' => '*****@*****.**']);
     $mailerTo = $mail->mailer->getToAddresses();
     $this->assertSame('*****@*****.**', $mailerTo[0][0]);
     $this->assertSame('*****@*****.**', $mailerTo[0][1]);
     $this->assertSame('*****@*****.**', $mailerTo[1][0]);
     $this->assertSame('John Doe', $mailerTo[1][1]);
     $this->assertSame('*****@*****.**', $mailerTo[2][0]);
     $this->assertSame('*****@*****.**', $mailerTo[2][1]);
     $this->assertSame('*****@*****.**', $mailerTo[3][0]);
     $this->assertSame('Jane Doe', $mailerTo[3][1]);
 }