Gossamer Forum
Home : Products : DBMan : Customization :

To send a welcome message to signup users

Quote Reply
To send a welcome message to signup users
Has someone the code to send a Welcome message to check the email address of new signup users. I have already posted this question in DBman Installation, and had an answer, but it was for NT Servers only. I run a Linux server.
Knowing that there is an "email address" field in the form filled out by members, my main problem is to extract this field from a hash (?) returned to db.cgi, in order to send a message, in a same way as for the "password lookup" answered in this forum by JPDeni.
If i am not clear, feel free to ask....
Parsifal
parsifal@noosph.org
Quote Reply
Re: To send a welcome message to signup users In reply to
It's pretty much the same as sending the email to users for a password lookup. Did you look at my mod for that?


------------------
JPD
Quote Reply
Re: To send a welcome message to signup users In reply to
Not exactly.
As I said, i am now able, by another way, to have usernames and passwords sent to users, on their request.
-----------
I am also able to send a message.
-------------
My problem is to extract the email address from the record filled out by users.
In your script, you use the PASS file to store email address. I do not, because email addresses are already stored in the .db file.
Here is a piece of code :
and it does not work.
I think that the part which sends mail works fine, but i do not succeed in extracting the userid's email address.
I had added this part of code in the sub html_add_success.
And i have the message "no recipient found in header". Therefore a field "email" is blank. What's is your opinion ?



dans &html_add_success; ?

here are some variables
$admin_email='xkeys\@noosph.org';
$mailprog= '/usr/sbin/sendmail';
$email='';
$login='';
$password='';

###############################mycode
##################mycode
#read the email address in xkeys.db
#######################
&checkaddress;

sub checkaddress {

$dbfile = "/home/noosph/noosph-www/cgi-bin/egf/mmb/adze/xkeys/xkeys.db";
open(FILE, "$dbfile") or print"unable to open: $dbfile.";
&lock(FILE);

@lines=<FILE>;
foreach $line ( @lines )
{
@fields=split(/\s*\|\s*/,$line);

if ($fields[1] eq $in{'userid'} ) {
$email=$fields[0];
$login=$fields[1];
$password=$fields[2]; }
&sendmymail;
}

&unlock(FILE);
close(FILE);




}


sub sendmymail {
open (MAIL, "|$mailprog -f$admin_email -t") &#0124; &#0124; die "Can't open $mailprog!\n";

print MAIL "To: $email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $dbname Account Information\n\n";



print MAIL "Your $dbname User ID is: $login\n";
print MAIL "Your $dbname password is: $password\n\n";

print MAIL "please contact $dbname support at: $admin_email\n";
print MAIL "if you have any questions.\n\n";

close (MAIL);
}


sub lock {
$LOCK_EX=2;
local($FILE)=@_;
flock($FILE, $LOCK_EX);
}

sub unlock {

$LOCK_UN=8;
local($FILE)=@_;
flock($FILE, $LOCK_UN);
}



#########end##########
Quote Reply
Re: To send a welcome message to signup users In reply to
Well, I wrote code to have new users just enter their username and email address and then send them a randomly generated password, in order to be sure the email address is correct. The downside is that the user can't have a password of his/her choice.

Is this what you want?


------------------
JPD
Quote Reply
Re: To send a welcome message to signup users In reply to
Just a part of it.
Just to be able to send a message to new users, by extracting their email address from the form they have filled out.
If the email address is not valid, i'll know it, because the mail will be returned to me.
Parsifal
Quote Reply
Re: To send a welcome message to signup users In reply to
Your email addresses are in your .db file, right? And you're using it in html_add_success, right? Then you don't have to include the code to open the file at all.

Change the line (in html_add_success)

&html_record(&get_record($in{$db_key}));

to

%rec = $get_record(in{$db_key});
&html_record(%rec);

Then just use your %rec variables to create the email.

print MAIL "To: $rec{'email'}\n";

If you're still having trouble, instead of trying to send an email message, have the script print out the variables on the web page. You can more easily see where you might be going wrong.


------------------
JPD
Quote Reply
Re: To send a welcome message to signup users In reply to
Hello JPDENI,

I tried your code, but i get across an error server.
At last, i found this. It works, and fine !

Providing you have the fields "Email", "Login", and "Password" in the db file,
it sends automatically to users their login/password/database name as soon as they
create a record.

Here is the code :


to put these two variables in the header

$admin_email='yourname@foo.org';
$mailprog= '/usr/sbin/sendmail';
***************************

in sub html_add_success {

after

|; &html_record(&get_record($in{$db_key})); ####leave this line

put

%rec=&get_record($in{$db_key});


open (MAIL, "|$mailprog -f$admin_email -t") &#0124; &#0124; die "Can't open $mailprog!\n";

print MAIL "To: $rec{'Email'}\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: Noosph : $Comm : Account Information\n\n";

print MAIL "Your network is: $Comm \n";
print MAIL "Your username is: $rec{'Login'}\n";
print MAIL "Your password is: $rec{'Password'}\n\n";


close (MAIL);

#####end

Note : This little piece of code will save me a LOT of time !

Thanx again.
Quote Reply
Re: To send a welcome message to signup users In reply to
I'm glad you got it figured out! Smile


------------------
JPD