# Email Form: break apart email address...How?



## T-BOT (Jul 24, 2006)

Before I spend hours figuring this out, maybe someone here can help? 

In a contact form where you ask the user to type in their Email address ([email protected]), I would like the user to type in *example* only then the user would select the @site.xxx from a drop down menu to send the complete email address.

So after the user sends the form information, I would receive the email field complete as [email protected] 

in other words, how can i break apart the email address on the form for the user and receive it complete?

hope this makes sense. 


any help appreciated.


:


----------



## aplusbowling (Dec 6, 2007)

What programming language are you using for the script to send the email?


----------



## T-BOT (Jul 24, 2006)

aplusbowling said:


> What programming language are you using for the script to send the email?


Copyright 1995-2002 Matt Wright formmail PERL script.  ...talk about old.

but any other email script you could recommend that would allow this function I need would do. 



:


----------



## perrolocodesigns (Oct 24, 2006)

There are way too many server extensions to do that efficiently. You would have to include all the major email servers (google), cable companies (roadrunner), phone companies (bellsouth), etc, and you still wouldn't cover folks with a business email like "ken @abctrucks.com". Even if you could know all of the server extensions that are in use, the drop-down list would be tens of thousands of choices. 

For a contact form, the user should be able to enter their entire email, or you'll be excluding many people from contacting you.


----------



## T-BOT (Jul 24, 2006)

perrolocodesigns said:


> There are way too many server extensions to do that efficiently. You would have to include all the major email servers (google), cable companies (roadrunner), phone companies (bellsouth), etc, and you still wouldn't cover folks with a business email like "ken @abctrucks.com".


Ken, I understand your point. 

But the project Im working ON the @company.xxx are specific cell phone service providers with gateways that deliver Emails as SMS. 



:


----------



## splathead (Dec 4, 2005)

I understand what you want to do and assume you want to do it that way so you don't get customers whose service you don't support?

If no one else chimes in with an answer, what about just having the customer enter their full address and then have that field validated for the correct carriers? If it is a carrier you don't support, the customer would get an error message explaining.


----------



## T-BOT (Jul 24, 2006)

splathead said:


> I...assume you want to do it that way so you don't get customers whose service you don't support?


Joe, yes and no. 

Yes I want to exclude users who DO NOT have a cell phone.

and No, I do not want to exclude users that do have a cell phone number.

ok, here is more info on the project to help you folks help me. 


Basically, a user with a cell phone number would type in their number in the email field (555 555 5555). Then they would choose their cell phone service provider from a dropdown menu (@TNT.xxx). In the actual value of the (@TNT.xxx) on the send form required it would be something like: @mail.whatever.TNT.xxx). 

Why would I not ask the user to type in [email protected] ? because most cell phone users do not know the cell phone service provider's email address gateway (@mail.whatever.TNT.xxx) .

One of the end purposes of this is to be able to receive payments by having a already signed up user type in their cell phone number ONLY to pay.. This function would internaly pull up the users CC and shipping info on the sellers system. 

Then a security code/number would be generated and sent to the user via SMS to the cell phone in real time. Then the user would type in the security number on the webpage to complete the transaction. 

Of course they would need to signup and login to a HTTPS server before any of it.


can you folks tell me how I can get the users imput tel # to attach itself to a @whatever.xxx dropdown menu off a web email form and receive the users complete email address? 


I cant figure it out. 


Help!!!!!! 



:


----------



## splathead (Dec 4, 2005)

It can be done with a calculated field in your underlying database. Not sure which database you are using, but the results of the calculated field would be: [user tele number]+ "@"+[carrier]


----------



## perrolocodesigns (Oct 24, 2006)

T-BOT said:


> Ken, I understand your point.
> 
> But the project Im working ON the @company.xxx are specific cell phone service providers with gateways that deliver Emails as SMS.:


Now that makes sense...good luck finding the best way to make it work.


----------



## Rodney (Nov 3, 2004)

Do you want to just receive the whole [email protected] as part of the form submission, or do you want the form submission to go to the [email protected] that the user selects?

I'm not much of a programmer, but I'm trying to wrap my head around what you're trying to do


----------



## Rodney (Nov 3, 2004)

Looking again at your post #7 above, I *think* what you can do is show the user one thing in the dropdown but actually have the form send YOU something different like: 


```
ATT
```
This would show the user "ATT" in the dropdown, but it would send you @txt.att.net when you get the form.

Hopefully this is in the right direction of what you're looking for?


----------



## splathead (Dec 4, 2005)

Rodney said:


> Looking again at your post #7 above, I *think* what you can do is show the user one thing in the dropdown but actually have the form send YOU something different like:
> 
> 
> ```
> ...


Rodney, she is trying to combine two different form questions into 1 answer.

Mobile Telephone Number:

Carrier: 

And she wants to get back an answer of [email protected]e.com as an example.


----------



## T-BOT (Jul 24, 2006)

Rodney said:


> ```
> ATT
> ```
> This would show the user "ATT" in the dropdown, but it would send you @txt.att.net when you get the form.


Yep, that is part of it and that I can do. 

but as joe said: 



> Rodney, she is trying to combine two different form questions into 1 answer.
> 
> Mobile Telephone Number:
> 
> ...


....above is what I need to do.

Im comfortable with Matt Wright formmail PERL script. 

Anyone outthere that can help me out with this one...don't be shy.  




:


----------



## splathead (Dec 4, 2005)

Lucy, how do you get the form answers? In a database or simply as an email? If a database, is it mysql?


----------



## aplusbowling (Dec 6, 2007)

In the PERL script there will be variables for your two fields("username" for the first part of the email and the "@whetever.xxx"). You will need to declare a new variable and combine (concatenate) the first two fields into this one. The new variable can then be saved to the database.

EX...

var1 = (the name of your first field)
var2 = (the name of your second field)
var3 = var1 + var2

I haven't used the PERL script in quite sometime, so I'm not sure of the exact syntax. If you want to paste the code into a PM and send it to me, I'll take a look. Be sure to let me know the field names in your form.


----------



## T-BOT (Jul 24, 2006)

splathead said:


> Lucy, how do you get the form answers? In a database or simply as an email? If a database, is it mysql?


right now Im trying to figure it out how to get the form answers as an email.

I would like to get it working this way for now (email answers). 


After, I may need to move into a database like mysql in order to do more with it (the answers)....

but for now, email answers will do. 

thanks again,




:


----------



## aplusbowling (Dec 6, 2007)

Did you find a solution?


----------



## T-BOT (Jul 24, 2006)

aplusbowling said:


> Did you find a solution?


not yet Tim.

this function is only a small element of what the project is about, but its holding me back because I can't continue without it. 


I have been working on other areas and they are ready. 

I was hoping someone would come along and say:

"here you go, download this ready to go form email script" ($$$) 

Im thinking of contacting a few code people around the web and see if I can get this out of the way by the end of next week.

Thanks for asking. 



:


----------



## aplusbowling (Dec 6, 2007)

It's been a while since I've used the PERL script for email, but send me code in an IM and I'll take a look at it. Did you see my post a couple posts back?


----------



## T-BOT (Jul 24, 2006)

aplusbowling said:


> It's been a while since I've used the PERL script for email, but send me code in an IM and I'll take a look at it. Did you see my post a couple posts back?


nope, I missed that post. 

you can download the script here (note it is a .txt file, you will need to change the extention to .pl)


```
www.t-bot.net/formmail.txt
```
Please have a look.

You can FTP into your cgi-bin, be sure to set permissions to 755  and change this line on the script to your website: 

*@referers = ('tims-site-example.com');*

...as for the actual html form, include this and change it to your website and email address:


```
<form method="POST" action="http://www.tims-site-example.com/cgi-bin/formmail.pl">
<input type=hidden name="recipient" value="[email protected]">
```
anything else you need let me know.

also, it does not need to be in Perl, if you can get this done with any other script language... not a problem.

thanks.



:


----------



## splathead (Dec 4, 2005)

I guess what I am not clear about is, since this is not going into a database but an email, this information will have to be reentered somewhere else anyway, correct? Why the big issue about the two pieces of the email address being together instead of next to each other on an email form?


----------



## aplusbowling (Dec 6, 2007)

PERL....ughhh!! No wonder I haven't used it in a while, still gives me a headache...LOL!

Can you post a link to the html form you are testing? I think PHP will be a better option for you. If I can see the html code, then I can customize a PHP email script.


----------



## rrc62 (Jun 2, 2007)

Something like this should work. Once you have the parts of the string you want to assemble, Perl is pretty good at doing the assembly. You can see in the script how the strings are brought in from the form and concatenated to form the end result. The script is simple and doesn't do any format checking. It just takes in some data and sends it out via email.

-----------------------------------------------------------------

#!/usr/local/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use CGI;

$query = new CGI;
$form-answer-1 = $query->param("form-answer-1");
$form-answer-2 = $query->param("form-answer-2");
$form-answer-3 = $query->param("form-answer-3");

$email-message = $form-answer-1 . form-answer-2 . form-answer-3;
$email-to = "info\@personalizedimprinting.com";
$email-from = "info\@personalizedimprinting.com";

######################################
##Send the eamil
######################################

&send_mail;

######################################
##Tell user email was sent
######################################

print "Content-type: text/html\n\n";
print


----------

