Jump to content

php email to only certain email addresses?


revo

Recommended Posts

Okay I'm new here and kinda new to PHP coding so I don't know if this is where to post it.

 

What I'm looking for is a script to email certain addresses, like what I want is someone to fill out a form and put their email address with out the @domain.tld, I want that as a drop down menu and when they submit it, it will email that address.

 

I have looked at some tutorials but all of them show you have to put in your email address but I want it to be so the user will get the email when they fill in the email address and select the drop down email account.

 

Any and all help is appreciated!

 

If you need any more information or I didn't explain it full please let me know.

Link to comment
Share on other sites

ok if your looking to code this yourself, youve come to the right place!

 

if your looking for a premade script try the snippets forum or http://www.hotscripts.com or similar.

http://www.phpfreaks.com/forums/index.php/board,41.0.html

 

if your looking for someone to code this for you go to the freelancing forum.

http://www.phpfreaks.com/forums/index.php/board,8.0.html

 

can you confirm if your willing to code this yourself?

 

 

cheers,

Link to comment
Share on other sites

how are you planning on emailing them if you don't know the @domain.ext part of the email address? you need to store the full email address in a database, and then take the email string and replace everything in the email address starting with the @ symbol with "" (nothing) and then make that appear in the drop down box and then make a script to email to that address when the form is submitted. if you don't know anything about php it will take you a while.

Link to comment
Share on other sites

I am willing to code it myself since I don't have anything to offer (I just now [like 5 minutes ago] got a speeding ticket.  >:(:( ). I am okay with HTML a little rusty (I have not coded in like 3 or so years.) I'm not as good with PHP however. This is what I have so far:

<?php
  $subject="test";
  $message="test";
  if (!isset($_POST["send"])){
    // no post data, display form
   ?>
   <form method="post" action="email.php">
  Phone Number: <input name="phonenumber" type="text" /><br /><br />
  Carrier: <select name="carrier">
  <option value="" selected>Carrier</option>
                                    
<option value="@message.alltel.com" >Alltel</option>
<option value="@txt.att.net" >AT&T/Cingular</option>
<option value="@metropcs.sms.us" >Metro PCS</option>
<option value="@messaging.sprintpcs.com" >Sprint</option>
<option value="@tmomail.net" >T Mobile</option>
<option value="@vtext.com" >Verizon</option>
  </select><br /><br />

  Message:<br />
  <textarea name="message" rows="15" cols="40">
  </textarea><br />
  <input type="submit" />
</form>
   <?php
}else{
   // found post data
   $to=$_POST['phonenumber']&['carrier'];
   // send mail :
   if (mail($to,$subject,$message,"From: $from\n")){
     // success
     echo "Mail sent successfully to $to.
";
   }else{
     // failure
     echo "Doh ! Sending failed.
";
   }
}
?>

I get an error on line 28: "$to=$_POST['phonenumber']&['carrier'];" Now I'm sure thats not how it is so posed to be and I'm going to get flamed for it but I'm a n00b I know this. Now I saved it as email.php. I guess what im really asking is how do add two variables or strings? together?

Link to comment
Share on other sites

Thanks for the fast replay! But I'm still getting an error on line 28: Parse error: syntax error, unexpected '[' in /home/revo/public_html/email.php on line 28

 

Edit:

Ok I saw you edited it with a new code will try it!

 

Edit 2: Okay that work.. well sorta I get no errors but it does not sent the message. I erased the first $message="test" to see maybe that had something to do with it but still nothing. After I hit Submit it's as if the page refreshes. Now like I said I'm new to PHP so correct me if I'm wrong but when you hit Submit shouldn't it display "Mail sent successfully to $to." or "Doh ! Sending failed." and not the form?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.