"Getting Started" email trigger.

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

"Getting Started" email trigger.

Postby wjm » Wed Jul 30, 2008 7:19 am

New to Xataface and excited about its potential. I'm working through the "Getting Started" guide. I've run into a problem at 'triggers'.

The following code in ...//FacultyOfWidgetry/tables/Course/Course.php never sends the email however the response code is always set and displays on the screen. (Email address changed for obvious reasons).
--
class tables_Course {

function afterInsert(&$record){
$response =& Dataface_Application::getResponse();

if ( mail('xxx@yyy.com', 'SubjectLine', 'MessageBody') ){
$response['--msg'] .= "\nEmail sent to xxx@yyy.com.";
} else {
$response['--msg'] .= "\nMail could not be sent at this time.";
}
}

}
?>
--
I read the forum and checked that my php is set up properly. I tested
with the following script sent via the command line & it worked fine.
--
<php>
--
I'm not sure what's going on. I took the mail line out of the condition and tried running it by itself -- still no email sent.

Any tips appreciated.
wjm
 
Posts: 3
Joined: Wed Jul 30, 2008 7:10 am

Postby shannah » Wed Jul 30, 2008 8:55 am

Your test script didn't go through (the forum stripped it). Try checking the "Disable HTML in this Post" box to post PHP code and HTML without PHPBB messing with it.

Now there are only 2 options:
1. The mail is not being sent properly.
2. The mail is being sent properly but is being filtered at the destination (most likely as spam).

I sometimes have trouble with mail sent from PHP being blocked as spam. In these cases I can usually fix the problem by adding Reply-to and From headers to the message.

In order to test which of the two problems are occurring, you may want to try to send emails to a few different email addresses (at different hosts). If none of them get through it doesn't prove that the mail is not being sent, but it makes it more probable.

The fact that PHP says that the mail is being sent usually means that it is. I can't recall ever being lied to by PHP in this capacity (even though in the short term I have often accused PHP of lying about such things - until I discover what the real problem is).

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby wjm » Wed Jul 30, 2008 9:07 am

2nd try on the test script
--
<?php
$res = mail('xxx@yyy.com', 'A test email', 'This is only a test');
if ( $res ) echo "Email test succeeded.. YOu should have a mail in your mailbox";
else echo "Email failed.";
?>
--
As per my earlier message .. the above script works and sends an email.

The test script and the actual Course.php script are sending to the same email address. The above script sends the message and the Course.php does not send the message.

I took your advice and tried sending to different email addresses. Again the Course.php script fails 100% of the time and the little test script works each time.

Hope that is useful. I appreciate your input.
wjm
 
Posts: 3
Joined: Wed Jul 30, 2008 7:10 am

Postby shannah » Fri Aug 01, 2008 8:03 am

If you have the same code in both places then it's time for a little debugging. You need to find out if it is even executing your beforeSave() method (or whatever trigger you are trying to use).

Try putting echo statements in various parts (followed by an exit call) to ensure that the code is being executed.


eg:
Code: Select all
echo "I'm here!!!! on line ".__LINE__." of file ".__FILE__; exit;


If the code is not being executed then one of the following conditions is true:
1. Your delegate class is not being read by PHP due to permissions or naming problems.
2. Your trigger is not being called because it has a naming problem.
3. Your trigger is in the wrong file.

If the code is being executed and you are convinced that PHP thinks it is sending the mail -- and the code to send mail is identical to your test script --- well that is pretty unlikely so continue to look elsewhere.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 6 guests

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