MailTask.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /*
  3. * $Id: MailTask.php 905 2010-10-05 16:28:03Z mrook $
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. *
  17. * This software consists of voluntary contributions made by many individuals
  18. * and is licensed under the LGPL. For more information please see
  19. * <http://phing.info>.
  20. */
  21. include_once 'phing/Task.php';
  22. /**
  23. * Send a message by mail()
  24. *
  25. * <mail to="user@example.org" subject="build complete">The build process is a success...</mail>
  26. *
  27. * @author Francois Harvey at SecuriWeb (http://www.securiweb.net)
  28. * @version $Id: MailTask.php 905 2010-10-05 16:28:03Z mrook $
  29. * @package phing.tasks.ext
  30. */
  31. class MailTask extends Task {
  32. protected $recipient;
  33. protected $subject;
  34. protected $msg;
  35. function main() {
  36. $this->log('Sending mail to ' . $this->recipient );
  37. mail($this->recipient, $this->subject, $this->msg);
  38. }
  39. /** setter for message */
  40. function setMsg($msg) {
  41. $this->setMessage($msg);
  42. }
  43. /** alias setter */
  44. function setMessage($msg) {
  45. $this->msg = (string) $msg;
  46. }
  47. /** setter for subject **/
  48. function setSubject($subject) {
  49. $this->subject = (string) $subject;
  50. }
  51. /** setter for recipient **/
  52. function setRecipient($recipient) {
  53. $this->recipient = (string) $recipient;
  54. }
  55. /** alias for recipient **/
  56. function setTo($recipient) {
  57. $this->recipient = (string) $recipient;
  58. }
  59. /** Supporting the <mail>Message</mail> syntax. */
  60. function addText($msg)
  61. {
  62. $this->msg = (string) $msg;
  63. }
  64. }