php mail to the entered address

Discussion in 'PHP' started by khan11, Oct 31, 2007.

  1. #1
    Hello guys!

    I want something like this:

    A form:
    my email(hidden in the script)

    To: (a text bar to enter email)
    Message: (body message)

    and a send button.

    What it do, people enter email and press send button. This sends email to the entered email from myemail address.


    thanks in advance..
     
    khan11, Oct 31, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Most basic example ever:

    
    mail($_POST['recipient'], 'Subject goes here', $_POTS['message'], 'From: You <you@example.com>');
    
    PHP:
    www.php.net/function.mail


    I guess you can make the form yourself?
     
    nico_swd, Oct 31, 2007 IP
    khan11 likes this.
  3. khan11

    khan11 Active Member

    Messages:
    615
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #3
    yes sure i can. Thank you so much for script. Let me do my own experiments now. ;)

    Actually trying to create an sms system for me so people wont need java applet to send free sms from my site. Hope u get.

    THanks again. If i need a help, i will ask again. + for u.

    Edit:Well this worked
    I need something, i want to show sent confirmation text, a bit confused how to do it. So, any help?
     
    khan11, Oct 31, 2007 IP
  4. bobb1589

    bobb1589 Peon

    Messages:
    289
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    if(mail($_POST['recipient'], 'Subject goes here', $_POTS['message'], 'From: You <you@example.com>')){
    echo "Mail Successfully sent.";
    }else{
    echo "Mail could not be sent.";
    }
    PHP:
     
    bobb1589, Oct 31, 2007 IP
  5. brendandonhue

    brendandonhue Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The above is vulnerable to header injection...you need to validate the e-mail address field before sending the message.
     
    brendandonhue, Oct 31, 2007 IP
  6. khan11

    khan11 Active Member

    Messages:
    615
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #6
    and how can i do that?

    i just know a little bit in php. making variables and using get commands lol
    so plz help.
     
    khan11, Oct 31, 2007 IP
  7. brendandonhue

    brendandonhue Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Use a library like Swift Mailer that isn't vulnerable to this issue.
     
    brendandonhue, Oct 31, 2007 IP