Results 1 to 31 of 31

Thread: sending e-mail to users

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    sending e-mail to users

    I want to automatically send an e-mail to a user once he/she has registered on my web site using the details from the registration form. Can someone show me how I can do this ?

  2. #2
    scoutt
    Guest
    that is pretty easy, what scripting can you use? cgi, php, asp

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    Hi scoutt

    I have successfully managed to create a user registration form and take this info and store it in a mySQL Database. I have done this using ASP.

    However, my web hosting co. use a Linux based server and do not support CDONTS for sending e-mail. I therefore have to get around the problem using a different scripting technology. Ideally I would like to use perl. Could you show me a way of doing this in perl, bearing in mind I know very little about perl.

    I would appreciate your help.

  4. #4
    scoutt
    Guest
    well I have some script at home so I have to wait. I am at work now. give me aday so I can write something up for you so you can understand it.

  5. #5
    scoutt
    Guest
    can I get the code for your form? that way I can make the script read your form variables. thanks

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    can i e-mail you the code ?

    my e-mail is:
    [email protected]

  7. #7
    scoutt
    Guest

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    I tried e-mailing you scoutt but I get an error:

    Sorry your message to [email protected] cannot be delivered. This account has been disabled or discontinued. - mta518.mail.yahoo.com

    Please advise.

  9. #9
    scoutt
    Guest
    that is odd, I just checked it 10 secs ago and I got in fine. try it again and if it doesn't work then I will give you another one

  10. #10
    scoutt
    Guest
    what all of the information do you want sent. just there name and address or everything.

  11. #11
    scoutt
    Guest
    ok here it is. I didn't know what information you wanted so I put it all in there.

    what you need to do is find out what the shebang line is something like this #!/usr/bin/perl that is default so it might be that. and you need to find out where your mail program is something like this /usr/sbin/sendmail

    to find that out you need to ask your server admin and he should tell you. other than that you need to put this scriopt in your cgi-bin folder and chmod it to 755. you can do that by the ftp program you use. if you right click on the file after you up load it, it might be in that menu.

    then you need to put this file in your form action field. action="cgi-bin/mail.cgi"

    if you need more than that let me know. also I could take some of the info out that is sent to them.

    change the .txt extension to .cgi

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    Scoutt,

    Many thanks for your help. I will download the script and give it a try.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    Hi Scoutt

    Question regarding your script. If I change the following line:

    <form name="frmUser" action="register.asp" method="POST" onSubmit="return VerifyData()">

    TO:

    <form name="frmUser" action"cgi-bin/mail.cgi" method="POST" onSubmit="return VerifyData()">

    Then how will I update the information from the form into my Database. The original action= line is calling register.asp which takes the form variables, opens a DB connection to mySQL and populates my Database.

    I want to populate my Database and send an e-mail to the user as soon as they have registered.

    Please can you advise ?

  14. #14
    scoutt
    Guest
    However, my web hosting co. use a Linux based server and do not support CDONTS for sending e-mail. I therefore have to get around the problem using a different scripting technology. Ideally I would like to use perl
    Maybe I misunderstood you. sorry I was stuck on sending them mail instead of registering them as well.

    now you could keep it as register.asp in your form and in your script that registers them you can call this mail script which will send them an email. I don't know ASP so I can't tell you how to call it. does it have an include or require. if so then you will probably need some hidden inputs so the mail script will send the right information

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    Hi Scoutt

    I have worked out how I am going to call the mail.cgi script from my asp page after populating my DB. The code is:

    Response.Redirect("../../cgi-bin/mail.cgi?email=strEmail?firstname=strFirstName?surname=strLastName?pass=strPassword")

    This line will call the cgi script that you wrote for me and pass the email, firstname, lastname and password to the mail.cgi script. This is the only info I want to send the user.

    I have modified your script to allow for this, however, because I am not very familiar with perl can you take a look at it and let me know if it looks ok.

    Also,

    I am not sure about the following lines:

    $recip = $email_for ;
    and
    $Form = $field{'form'} ;

    and where do I put MY e-mail address (i.e the senders e-mail address)


    Many thanks.

  16. #16
    scoutt
    Guest
    ok sorry it took so long to get back, but the site was down for most of the day. now it looks fine and you can delete the mail_for variable. I forgot that it was in there. you asked if you wanted your email in there so it will go to you or what?

    but if you want it to go to you just amke a hidden input field and make the value your email and the name="mail_for". then you will have to change this line

    print MAIL "To: $email\n";

    to read

    print MAIL "To: $recip\n";

    or you can make this line read

    print MAIL "From: $recip\n";

    and the email will say it is from you. and you can delete the Form - ".$Form.", that was just to show what form they sent.

    does that help?

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    understood, thanks.

    one more question:

    When I'm using the following bit of code to pass variables/parameters (obtained from my form) to my mail.cgi script:

    Response.Redirect "cgi-bin/mail.cgi?strFirstName?strLastName?strEmail?strPassword"

    How do I assign these values to the local variables inside the cgi script ? How do you get cgi to accept arguments ???

    i.e

    $firstname = ;
    $surname = ;
    $email = ;
    $pass = ;

    Any ideas ?

  18. #18
    scoutt
    Guest
    well you could try having hidden inputs in your response.asp script. so it would look something like this
    <input type=hidden value=<% ".$strFirstName." %> name=FirstName>
    nor sure if you need the "." in there since I don't know asp that much. but it should be something like that

    the "value" is the variable from your form, the "name" is for the mail.cgi script

    then when you redirect it should populate the variables in the mail.cgi script.

    does tha tmake since. so you would have a number of hidden inputs depending on how many variables you have.

    I think that should work. if not let me know

  19. #19
    scoutt
    Guest
    actually if you are going to do

    Response.Redirect "cgi-bin/mail.cgi?strFirstName?strLastName?strEmail?strPassword"

    then it would look like this

    Response.Redirect "cgi-bin/mail.cgi?FirstName=$strFirstName&LastName=$strLastName&Email=$strEmail&Password=$strPassword"
    notice the "&" and I don't think I would use the same name for the name and variable. it might get confusing to the script I think, the name has to be what is in the mail.cgi script.

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    I have tested the code with the following line:

    Response.Redirect "cgi-bin/mail.cgi?firstname=$strFirstName"

    I get an error in the cgi script:

    firstname must be filled in

    the variable strFirstName is not being read by the cgi !

    any ideas ?

  21. #21
    scoutt
    Guest
    ya, I don't think I had the variables right that you are using in the asp script.
    change this line
    Code:
    if ($firstname eq "") {
    	$message = $message.$errmsg ;
    	$found_err = 1 ; }
    and other error variables to your form variables. eg-strFirstName...

    you might also have to change the variables that are being sent to your users. in the Print " statements towards the bottom. I made the script from your form not from your asp script.

  22. #22

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    sorry scoutt i'm a bit confused now. Can you elaborate on your last post please ? I'm not quite sure which changes i need to make to my mail.cgi script

    thanks.

  23. #23
    scoutt
    Guest
    sorry, in your mail.cgi script change this line, changes in bold..
    Code:
    if ($firstname eq "") {
    	$message = $message.$errmsg ;
    	$found_err = 1 ; }
    
    to 
    
    if ($strfirstname eq "") {
    	$message = $message.$errmsg ;
    	$found_err = 1 ; }
    and look at the other variables, in your mail.cgi script look at these lines
    print MAIL "To: $email\n";
    print MAIL "From: $firstname\n";

    and see if you need to change thme as well to your form variables. or send me the form again and I will change them.

  24. #24

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    Hi scoutt, i'm afraid i'm still having problems passing the parameters to the cgi script. I have sent you the asp and cgi script by e-mail. I'd appreciate it if you could take a look when you have a moment.

    thanks.

    ps In the asp script I am taking the form variables and assigning them to variables like this:

    strFirstName = Request.Form("firstname")
    strSurname = Request.Form("surname")
    strEmail = Request.Form("email")
    strPassword = Request.Form("password")

    and then passing them to the cgi script like this:

    Response.Redirect "../../cgi-bin/mail.cgi?$firstname=strFirstName?$surname=strSurname?$email=strEmail?$password=strPassword"

  25. #25

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    I have tried sending the scripts by e-mail twice and get an error:

    Sorry your message to [email protected] cannot be delivered. This account has been disabled or discontinued. - mta422.mail.yahoo.com

    Do you have another e-mail address ?

  26. #26
    scoutt
    Guest
    I don't know what is wrong with yahoo, I am at work so I have the scripts here. is tha tall the variables you are using?
    strFirstName = Request.Form("firstname")
    strSurname = Request.Form("surname")
    strEmail = Request.Form("email")
    strPassword = Request.Form("password")

    I will take a look at it and get it changed for ya.

  27. #27
    scoutt
    Guest
    ok here try this one.

  28. #28
    scoutt
    Guest
    by the way I do have another email. if you want to send them to my house then send them to [email protected] but I won't get a chance to look at them until at least 6 hours from now.

  29. #29
    scoutt
    Guest
    ok I thnk I got it. but i want to try something. when you redirect it don't put the stuff behind it. just leave it as mail.cgi. I thing it will work if you just leave it as plain mail.cgi. I took out the error statements since you already check for the inputs. let me know how it works.

    also don't change anthing in the script. let em know if it works like it is.

  30. #30

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    I have tried this but the mail.cgi script doesn't work, it comes up with a 'this page cannot be displayed' message.

    I have ensured not to make any changes to the mail.cgi and I have done chmod 755 but no luck.

    any ideas ?

  31. #31
    scoutt
    Guest
    ok check and make sure that this line is correct
    #!/usr/bin/perl

    I had to change it so it will work on my computer and can't remember if I changed it back.

    I can't remember what line was in there so make sure it is the correct on efor your server. other than that can you see your error.log file and see where the problem is. it should work no problem. I didn't see anything else that might have stopped it.

    sorry that this is taking so long.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width