This topic is locked
[SOLVED]

 Send mail to each registered user

3/25/2010 11:43:24
PHPRunner General questions
L
lordkain2 author

Hi, I have this tables:
"USERS_DATA"

ID

Savings

Loans

User_ID

Date
"Users"

User_ID

Name

Pass

*Email
Can I send an email to every user with their Savings and Loans data? Any idea how to do this (if is possible)?
Thanks.
PS. I probably hire to do the work, anyone interested?

Sergey Kornilov admin 3/25/2010

You can check this article for inspiration:

http://xlinesoft.com/phprunner/docs/send_email_to_email_addresses_from_user_table.htm
If you need help with coding feel free to contact support team directly at http://support.xlinesoft.com

L
lordkain2 author 4/7/2010



You can check this article for inspiration:

http://xlinesoft.com/phprunner/docs/send_email_to_email_addresses_from_user_table.htm
If you need help with coding feel free to contact support team directly at http://support.xlinesoft.com


Hello, I saw the article and it is for:

Add page: Before record added; Add page: After record added; Edit page: Before record updated; Edit page: After record updated events.
It is possible to use this in Import: AfterImport event? I want to import records and then send an email with this fields:
From Users : User_ID, Name

From Users_Data: Savings, Loans, Date.
Thanks

G
glazer 4/7/2010



Hi, I have this tables:
"USERS_DATA"

ID

Savings

Loans

User_ID

Date
"Users"

User_ID

Name

Pass

*Email
Can I send an email to every user with their Savings and Loans data? Any idea how to do this (if is possible)?
Thanks.
PS. I probably hire to do the work, anyone interested?


This what i do in one of my application:
global $dal;

$LoginDetails = $dal->Table("Login");

$rs = $LoginDetails->QueryAll();
while ($data = db_fetch_array($rs))

{
$email=$data["Email"].", ";

$from="mail@fred.com";

$msg= $values["Message"];

$subject=$values["Subject"];

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"]."
";

}

L
lordkain2 author 4/8/2010



This what i do in one of my application:
global $dal;

$LoginDetails = $dal->Table("Login");

$rs = $LoginDetails->QueryAll();
while ($data = db_fetch_array($rs))

{
$email=$data["Email"].", ";

$from="mail@fred.com";

$msg= $values["Message"];

$subject=$values["Subject"];

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"]."
";

}


Can you please show me an example using two tables?
Thanks.

P
patricktrujillo 5/3/2010

I am trying to accomplish the same thing. Using "queryall()" will actually send an email to "all" the users within the email field under the table specified. But what if you want to send an email to one specific user?
I am trying this:
global $dal;

$tblUsers = $dal->Table("employees");

$rs = $tblUsers->Query("email = 'email'"); ------ or $rs = $tblUsers->Query("id = '%id%'");

while ($data = db_fetch_array($rs))
As you can see, I am using just "Query" instead of "QueryAll()". I am actually wanting to send an email that is specific upon the "id" of the record I am editing. The "id" of the record I am editing should fall back on my employees table which has the "email" field that contains the email address that is specific to the id of the employee.
Anyone?

J
Jane 5/4/2010

Patrick,
all entered values are in the $values array. So you can use this code in your event:

$rs = $tblUsers->Query("id = '".$values["FieldName"]."'","");



where FieldName is your actual field name.

P
patricktrujillo 5/6/2010

Jane,
The code you provided is not working. The syntax and all that checks ok, but no email is being sent. Here is the full code I am using.
global $dal;

//select emails from Users table

$tblUsers = $dal->Table("employees");

$rs = $tblUsers->Query("id = '".$values["email"]."'","");

while ($data = db_fetch_array($rs))

{

$email=$values["email"].", ";

$from="patrick@bhioffice.com";

$msg="Check what's hot this season";

$subject="Monthly newsletter";

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"]."
";

}
I have users in the "employees" table that have a specific "id", along with that "id" they have their "email". Once an employee is entered into the db, that is fine. But when I go to add the "employeeinfo", and complete all the info required, it should email that specific employee that his/her info has been added.
What do I have out of place here?

P
patricktrujillo 5/10/2010



Jane,
The code you provided is not working. The syntax and all that checks ok, but no email is being sent. Here is the full code I am using.
global $dal;

//select emails from Users table

$tblUsers = $dal->Table("employees");

$rs = $tblUsers->Query("id = '".$values["email"]."'","");

while ($data = db_fetch_array($rs))

{

$email=$values["email"].", ";

$from="patrick@bhioffice.com";

$msg="Check what's hot this season";

$subject="Monthly newsletter";

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"]."
";

}
I have users in the "employees" table that have a specific "id", along with that "id" they have their "email". Once an employee is entered into the db, that is fine. But when I go to add the "employeeinfo", and complete all the info required, it should email that specific employee that his/her info has been added.
What do I have out of place here?
bump bump

Sergey Kornilov admin 5/10/2010

patricktrujillo,
you need to troubleshoot your code. As a first step - print SQL query on the web page and execute it against your database to make sure it returns data.
Then, instead of actually sending the email, print email address and other info on the page to make sure it looks right.
You can learn some troubleshooting techniques at http://xlinesoft.com/phprunner/docs/debugging_tips.htm