CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Sending Email after Registration

Print topic Send  topic

Author Message
Graham Pearson
Posted: 07/04/2005, 5:53 AM

I am working on a CCS 2.3 Project where I would like to send an email to
the new user. I have created the email text in a file which I named
emailregister.tpl and within my index2_events.php I have the following
code which generates an email to the user with the correct headers but
the message body is blank. Does anyone have a Tutorial on how to handle
this?

global $members;
$login = $members->login-GetValue();
$email = $members->email->GetValue();
$rdate = $members->rdate->GetValue();
$activatelink = $_SERVER['HTTP_HOST'] . "/confirm.php?mid=" .
(urlencode($login)) . "&stamp=" . $rdate;
$emailTemplate = new clsTemplate();
$emailTemplate->LoadTemplate("emailregister.tpl", "main");
$emailTemplate->SetVar("fname", $members->fname->GetValue());
$emailTemplate->SetVar("lname", $members->lname->GetValue());
$emailTemplate->SetVar("login", $members->login->GetValue());
$emailTemplate->SetVar("link", $activatelink);
$emailTemplate->parse("main", false);
$emailBlock = $emailTemplate->getname("main", true);
$headers = "From: <fromAddress@domain.com>\r\n";
$headers .= "Reply-To: <fromAddress@domain.com>\r\n";
$headers .= "Return-Path: <fromAddress@domain.com>\r\n";
$headers .= "X-Mailer: PHP/" . phpversion . "\r\n";
$headers .= "X-Priority: 3\r\n";
$message = $emailTemplate->globals[$emailBlock];
mail($email, "EMail Subject", $emailBlock, $headers);
xbill99
Posted: 07/08/2005, 12:03 PM

I was looking to do something similiar with CCS -
customized emails based on certain events.

I was planning on having an email template file and then customize
parameter fields based on values from the current page or session variables. (much like the sample code)

Did you get this to work? Or does someone else have a better
approach?

thanks,
-bill
Damian Hupfeld
Posted: 07/09/2005, 10:01 PM

I have been looking at this recently and am about to try the following
solution.

Create your HTML code for the page you want to send. Split it into 3
sections

FIRST section starts at <html> and goes to start of dynamic content to
send..
-------
|

Second section is your dynamic content
[]

THIRD section starts at the end of the dynamic section and goes to the end
of the </html> tag.

Create a table with two entries

FIRST
THIRD

In your User Registration Grid insert 2 HIDDEN fields and set them to
contain FIRST and THIRD.

In your actual page place a SEND EMAIL ACTION on the ON CLICK of the SUBMIT
button.

Fill out your options (eg mail server, from address, subject, set HTML to
TRUE etc) and for the MESSAGE you will enter the code manually in the
REGISTRATION_EVENTS.PHP page and it might look something like this:

$message = $update->FIRST->GetText()."Username
<b>".$update->USERNAME->GetText()."</b><br>Password
<b>".$update->PASSWORD->GetText()."</b><br>".$update->THIRD->GetText();

That should build your message to look like:

--------------------------------
| [username is JOHN SMITH] |
| [password is PASSWORD ] |
--------------------------------

Or so my thinking goes!

regards
Damian Hupfeld
http://www.nexthost.com.au/services.php







"xbill99" <xbill99@forum.codecharge> wrote in message
news:542cece0c7acf1@news.codecharge.com...
>I was looking to do something similiar with CCS -
> customized emails based on certain events.
>
> I was planning on having an email template file and then customize
> parameter fields based on values from the current page or session
> variables.
> (much like the sample code)
>
> Did you get this to work? Or does someone else have a better
> approach?
>
> thanks,
> -bill
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Graham Pearson
Posted: 07/10/2005, 7:09 PM

This has been solved and what I did is listed below. I inserted my own
code within index2_events.php file with:

global $members;
$login = $members->login->GetValue();
$email = $members->email->GetValue();
$rdate = $members->rdate->GetValue();
$activelink = $_SERVER['HTTP_HOST'] . "/confirm.php?mid="
..(urlencode($login)) . "$stamp=" . $rdate;
$emailtemplate = new clsTemplate();
$emailtemplate->LoadTemplate("register.mtl", "main");
$emailtemplate->SetVar("fname", $members->fname->GetValue());
$emailtemplate->SetVar("lname", $members->lname->GetValue());
$emailtemplate->SetVar("login", $members->login->GetValue());
$emailtemplate->SetVar("pswd", $members->pswd->GetValue());
$emailtemplate->SetVar("link", $activelink);
$emailtemplate->parse("main", true);
$message = $emailtemplate->globals[$emailblock];
$headers = "{All of the Email Headers with one Header per line";
$headers .= "{Another Header Line. Etc";
mail($email, "Email Message Subject", $message, $headers);




Damian Hupfeld wrote:
> I have been looking at this recently and am about to try the following
> solution.
>
> Create your HTML code for the page you want to send. Split it into 3
> sections
>
> FIRST section starts at <html> and goes to start of dynamic content to
> send..
> -------
> |
>
> Second section is your dynamic content
> []
>
> THIRD section starts at the end of the dynamic section and goes to the end
> of the </html> tag.
>
> Create a table with two entries
>
> FIRST
> THIRD
>
> In your User Registration Grid insert 2 HIDDEN fields and set them to
> contain FIRST and THIRD.
>
> In your actual page place a SEND EMAIL ACTION on the ON CLICK of the SUBMIT
> button.
>
> Fill out your options (eg mail server, from address, subject, set HTML to
> TRUE etc) and for the MESSAGE you will enter the code manually in the
> REGISTRATION_EVENTS.PHP page and it might look something like this:
>
> $message = $update->FIRST->GetText()."Username
> <b>".$update->USERNAME->GetText()."</b><br>Password
> <b>".$update->PASSWORD->GetText()."</b><br>".$update->THIRD->GetText();
>
> That should build your message to look like:
>
> --------------------------------
> | [username is JOHN SMITH] |
> | [password is PASSWORD ] |
> --------------------------------
>
> Or so my thinking goes!
>
> regards
> Damian Hupfeld
> http://www.nexthost.com.au/services.php
>
>
>
>
>
>
>
> "xbill99" <xbill99@forum.codecharge> wrote in message
>news:542cece0c7acf1@news.codecharge.com...
>
>>I was looking to do something similiar with CCS -
>>customized emails based on certain events.
>>
>>I was planning on having an email template file and then customize
>>parameter fields based on values from the current page or session
>>variables.
>>(much like the sample code)
>>
>>Did you get this to work? Or does someone else have a better
>>approach?
>>
>>thanks,
>>-bill
>>---------------------------------------
>>Sent from YesSoftware forum
>>http://forums.codecharge.com/
>>
>
>
>
xbill99
Posted: 07/11/2005, 8:25 AM

Thanks for the update-

I have been working with the code to adapt it...

I have been working with a register.mtl something like:

<!-- BEGIN main -->

Dear {fname},

message text ....

<!-- END main -->

It does not seem to be parsing correctly- when I var_dump
the $message variable it is empty...

Is there any special format for the or naming
convention for register.mtl file?

thanks,
-bill
xbill99
Posted: 07/11/2005, 9:12 AM

I found the problem with the template file - I had to use:

$emailtemplate->LoadTemplate(PathToCurrentPage ."register.mtl", "main","");

to load the correct template.

The message variable code still doesn't seem right- ie:

$message = $emailtemplate->globals[$emailblock];

I had to use something like:

$message = $emailtemplate->globals["//main/main"];

to get the message text from the Template object.

Other than that- it seems to be working...

-bill

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.