Results 1 to 4 of 4

Thread: PHP form to email help

  1. #1
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default PHP form to email help

    I have everything working on a php form to email, the only issue is the emails are coming to me as CGI-Mailer [cgi-mailer@perfora.net]. Is their something I can drop into my php sending code to display something specific in the address? Like maybe the applicants email address or name or both?


    -- nate

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Well, as I recall - cgi displays like this(first display, then code):
    Code:
    Name: Bob Frednik
    <input type="text" name="Name" />
    And someone typed Bob Frednik, so why don't you try:
    Code:
    <input type="text" name="Email" />
    Change the highlighted as desired.

    I hope this helps,
    Nile
    Jeremy | jfein.net

  3. #3
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default

    I think there is some confusion here.

    The html and php are working fine and displaying fine. When the emails come to me they are being sent to my junk box right away because they have the sender name and email address of "CGI-Mailer [cgi-mailer@perfora.net]" I want to assign a specific name to the emails or have the applicants email address displayed not the defualt name and email address of "CGI-Mailer [cgi-mailer@perfora.net]"

  4. #4
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    I think you are referring to the header within the mail function.

    You can change the from to be anything you like. For example you could take the person's email:

    Code:
    $email = $_POST['email'];
    and then add this to the header, which also specifies whether the email will be in HTML or text format.

    The mail function is made up of 5 parameters, 2 of them being optional.

    These are "to, subject, message, headers, parameters".

    You only need the first 4 to get what you want.

    So you can construct your message like this:

    Code:
    $to = "yourmail@mail.com";
    $subject = "Subject here"; /* You could make this dynamic by allowing the user to enter it through an input box*/
    $message = "Hello, this is my message";
    $header = "From: Their Name <" . $email . ">";
    
    // And then to send it
    
    mail($to, $subject, $message, $header);
    Hope this clears it up for you.

    You can have any email address by changing the header really.

    But it must always be in the format: "From: Jack <jack@mail.com>";

    Good luck!

Bookmarks

Posting Permissions

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