This topic is locked

Sending Email to User

8/26/2009 4:26:55 AM
PHPRunner General questions
S
swanside author

hello.
On my tables I have a labour table. This has EngineerName field in it.

When a new line is added to the labour table I want to send a simple email to the engineer concerened based upon the EngineerName
The Engineers Email is in a different table, called Account>Email
SO my tableas are as follows
labour>

EngineerName

InvoiceNo (PK)

account>

EngineerName

Email

$email="EngineerName";

$message="Please Update Your PDA";

$subject="You Have a new Job";

mail($email, $subject, $message);


Can this be done easily or should I add the email field to the labour table?
Thanks

Paul

J
Jane 8/26/2009

Paul,
you can select Engineer email from Account table in this event:

global $dal;

$rs = $dal->account->Query("EngineerName='".$values["EngineerName"]."'","");

$data = db_fetch_array($rs);

$email = $data["EngineerName"];
S
swanside author 8/28/2009



Paul,
you can select Engineer email from Account table in this event:

global $dal;

$rs = $dal->account->Query("EngineerName='".$values["EngineerName"]."'","");

$data = db_fetch_array($rs);

$email = $data["EngineerName"];



\\Thanks Jane.
Sorry for the delay, just got back from holidays.
Will try it over the weekend.
Paul.

S
swanside author 8/28/2009

Any Ideas why this happens?
Thanks

Paul
PHP error happened
Technical information

Error type 2

Error description mail() [function.mail]: SMTP server response: 503 5.5.2 Need Rcpt command.

URL localhost/email/labour_add.php?

Error file D:\email\include\labour_events.php

Error line 149

SQL query select * from account where Engineer_Note=''

S
swanside author 8/28/2009

Forgot to post my tables.

They are a bit different from the original idea, but I think I have changed them correctly

global $dal;

$rs = $dal->account->Query("Engineer_Note='".$values["email"]."'","");

$data = db_fetch_array($rs);

$email = $data["email"];

$message="Please Update Your PDA";

$subject="Please Update Your PDA";

mail($email, $subject, $message);




labour

Field Type Null Default Comments

Job_No varchar(50) No

Engineer_Name varchar(50) No

Paying_Rate double(7,2) Yes NULL

EngineerId int(10) Yes NULL

Working_Hrs double(7,2) Yes NULL

Sheet_Returned tinyint(1) Yes NULL

Invoice double(7,2) Yes NULL

Send_To_Invoice tinyint(2) Yes NULL

PDAAllocation varchar(100) Yes NULL
account

Field Type Null Default Comments

Engineer_Note varchar(50) Yes NULL

Telephone varchar(50) Yes NULL

EngineerId int(11) No

User_Name varchar(50) Yes NULL

Password varchar(50) Yes NULL

Staff_Name varchar(50) Yes NULL

Status smallint(5) Yes NULL

Enabled tinyint(1) No

Group_ID varchar(20) No

email varchar(30) Yes NULL

J
Jane 8/28/2009

Hi,
please make sure $data["email"] is not empty:

echo $data["email"];

if ($data["email"])

{

$email = $data["email"];

$message="Please Update Your PDA";

$subject="Please Update Your PDA";

mail($email, $subject, $message);

}
S
swanside author 8/29/2009

Hi Jane,
I tried this code

global $dal;

$rs = $dal->account->Query("Engineer_Note='".$values["Engineer_Note"]."'","");

$data = db_fetch_array($rs);

echo $data["email"];

if ($data["email"])

{

$email = $data["email"];

$message="Please Update Your PDA";

$subject="Please Update Your PDA";

mail($email, $subject, $message);

}


But no email arrives at any addresses. There is no errors when I complete the request

S
swanside author 9/3/2009

Hi,

DOes anybody have any ideas on this please?
I do not get any errors, but I do not get the emails either?
Cheers
Paul.