Question: There is a containment `OneToOne` relationship `Library -- Boss`:

```
Library --(Cascade)--> Boss
Boss    --(No Action)--> Library

```

Use case: replace boss. Replace means remove old value from database, save new value in database and set new value of the relationship. If I set a new boss and save the context, new boss is inserted, relationship is set to the new boss, but the old boss is not removed, it only gets library key nullified. How would I remove old boss complete from database?

Answer: 
You need to remove the line:

```
$emailSent = true;

```

And change the mail send line to

`$emailSent = mail($emailTo, $subject, $body, $headers);`

This sets $emailSent to true if the email is accepted for delivery. [PHP Mail](http://php.net/manual/en/function.mail.php)
Instead of

```
mail($emailTo, $subject, $body, $headers);

    // set our boolean completion value to TRUE
    $emailSent = true;

```

do

`$emailSent = mail($emailTo, $subject, $body, $headers);`

otherwise you'll be hardcoding the result, why would you say that the email has been sent if you don't know? what are you, some kind of liar?