Quick question on email function [SOLVED]

A place for users and developers of the Xataface to discuss and receive support.

Quick question on email function [SOLVED]

Postby jhenry » Wed Apr 28, 2010 7:09 pm

Quick question on the email functions. I setup an afterInsert as per the Triggers Wiki using the following code:

Code: Select all
function afterInsert(&$record){
      /**
     * Trigger that is called after Course record is inserted.
     * @param $record Dataface_Record object that has just been inserted.
     */


   $response =& Dataface_Application::getResponse();
        // get reference to response array

    if ( mail('jason@mail.com', 'Record Update-Infinity', 'A Workorder has been entered.') ){
        $response['--msg'] .= "\nEmail sent to jason@mail.com successfully.";
    } else {
        $response['--msg'] .= "\nMail could not be sent at this time.";
    }
}


I only get the Mail could not be sent at this time message. Is this automatically accessible or do I have to load the email module?

TIA

Jason
Last edited by jhenry on Fri Apr 30, 2010 6:18 pm, edited 1 time in total.
Do not mistake understanding for realization, and do not mistake realization for liberation....Tibetan Saying.
jhenry
 
Posts: 58
Joined: Sun Jul 12, 2009 1:20 pm
Location: Florida

Re: Quick question on email function

Postby tomhousley » Thu Apr 29, 2010 8:45 am

Hi Jason,

I use the following to send emails for afterUpdate function, but the same principle applies.

Code: Select all
$to      = 'FirstName LastName <name@email.com>';
$subject = 'Email Subject';
$message = 'Email Message';
$headers = 'FirstName LastName <name@email.com>' . "\r\n" .
   'Reply-To: name@email.com';
   
//php mail function//
mail($to, $subject, $message, $headers);


More information on the php mail function here: http://php.net/manual/en/function.mail.php

All the best, Tom
tomhousley
 
Posts: 52
Joined: Thu Feb 26, 2009 1:02 am
Location: United Kingdom

Re: Quick question on email function

Postby jhenry » Thu Apr 29, 2010 2:33 pm

Thanks for the response Tom that looks much simpler and cleaner to maintain. Is there any other setup as far as sendmail or do I need to set up the email module in dataface to make this work or is the functionality all handled by php?

TIA,
Jason
Do not mistake understanding for realization, and do not mistake realization for liberation....Tibetan Saying.
jhenry
 
Posts: 58
Joined: Sun Jul 12, 2009 1:20 pm
Location: Florida

Re: Quick question on email function

Postby tomhousley » Fri Apr 30, 2010 4:24 am

Hi Jason,

As far as I'm aware it's all handled by PHP.

I used shared hosting for my xataface applications and it works out of the box - so to speak. I don't have the email module installed.

All the best, Tom
tomhousley
 
Posts: 52
Joined: Thu Feb 26, 2009 1:02 am
Location: United Kingdom

Re: Quick question on email function

Postby jhenry » Fri Apr 30, 2010 6:18 pm

Thanks for the assistance Tom I checked my php logs and saw where I was getting errors saying I did not have sendmail installed. I installed it and it looks like it is working. If I am not mistaken most ISPs like you host yours on have that for webmail. Or at least some type of mail transport agent. I should have known. Thanks again.

Jason
Do not mistake understanding for realization, and do not mistake realization for liberation....Tibetan Saying.
jhenry
 
Posts: 58
Joined: Sun Jul 12, 2009 1:20 pm
Location: Florida


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 7 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved