PHPMailer::send PHP Method

send() public method

Uses the sending method specified by $Mailer.
public send ( ) : boolean
return boolean false on error - See the ErrorInfo property for details of the error.
    public function send()
    {
        try {
            if (!$this->preSend()) {
                return false;
            }
            return $this->postSend();
        } catch (phpmailerException $exc) {
            $this->mailHeader = '';
            $this->setError($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }
            return false;
        }
    }

Usage Example

Example #1
16
 /**
  * Tests removal of duplicate recipients and reply-tos.
  */
 public function testDuplicateIDNRemoved()
 {
     if (!$this->Mail->idnSupported()) {
         $this->markTestSkipped('intl and/or mbstring extensions are not available');
     }
     $this->Mail->clearAllRecipients();
     $this->Mail->clearReplyTos();
     $this->Mail->CharSet = 'utf-8';
     $this->assertTrue($this->Mail->addAddress('test@françois.ch'));
     $this->assertFalse($this->Mail->addAddress('test@françois.ch'));
     $this->assertTrue($this->Mail->addAddress('test@FRANÇOIS.CH'));
     $this->assertFalse($this->Mail->addAddress('test@FRANÇOIS.CH'));
     $this->assertTrue($this->Mail->addAddress('*****@*****.**'));
     $this->assertFalse($this->Mail->addAddress('*****@*****.**'));
     $this->assertFalse($this->Mail->addAddress('*****@*****.**'));
     $this->assertTrue($this->Mail->addReplyTo('test+replyto@françois.ch'));
     $this->assertFalse($this->Mail->addReplyTo('test+replyto@françois.ch'));
     $this->assertTrue($this->Mail->addReplyTo('test+replyto@FRANÇOIS.CH'));
     $this->assertFalse($this->Mail->addReplyTo('test+replyto@FRANÇOIS.CH'));
     $this->assertTrue($this->Mail->addReplyTo('*****@*****.**'));
     $this->assertFalse($this->Mail->addReplyTo('*****@*****.**'));
     $this->assertFalse($this->Mail->addReplyTo('*****@*****.**'));
     $this->buildBody();
     $this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
     // There should be only one "To" address and one "Reply-To" address.
     $this->assertEquals(1, count($this->Mail->getToAddresses()), 'Bad count of "to" recipients');
     $this->assertEquals(1, count($this->Mail->getReplyToAddresses()), 'Bad count of "reply-to" addresses');
 }
All Usage Examples Of PHPMailer::send