+ Reply to Thread
Results 1 to 4 of 4

Thread: Need help with php mail

  1. #1
    supermix is offline x10Hosting Member supermix is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    30

    Need help with php mail

    Hi is there a way for me to change the from header in the php mail function as it displays supermix@lotus.x10hosting or something like that, and also the return path.

  2. #2
    dickey's Avatar
    dickey is offline x10 Sophmore dickey is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    128

    Re: Need help with php mail

    Just utilize the headers options in the mail() function.

    e.g.

    PHP Code:
      $to="user@server.com";
      
    $subject="Mail Topic";
      
    $message="The mail contents.... blah blah blah...";
      
    $headers ="From: Sender Name <sender@email.address>";
      
    $headers.="Return-path: email-address@receivingthe.reply";
      
    $headers.="CC: another@email.tosendto";
      
      
    mail($to,$subject,$message,$headers); 
    Don't get me wrong as I believe if and when I help someone I also help myself whereby whatever someone learns I also learn.

    But I will also accept credits or reps if you really want to part with it.

  3. #3
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: Need help with php mail

    Most of what dickey writes is right, but he made a very important mistake:
    the headers have to be separated by \r\n, or nobody will ever know what you're trying to say...
    The code has to be:
    PHP Code:
      $to="user@server.com";
      
    $subject="Mail Topic";
      
    $message="The mail contents.... blah blah blah...";
      
    $headers ="From: Sender Name <sender@email.address>\r\n";
      
    $headers.="Return-path: email-address@receivingthe.reply\r\n";
      
    $headers.="CC: another@email.tosendto";
      
      
    mail($to,$subject,$message,$headers); 
    Real programmers don't document their code - if it was hard to write, it should be hard to understand.

  4. #4
    supermix is offline x10Hosting Member supermix is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    30

    Re: Need help with php mail

    So it is correct but needs the \r\n.

    Okay I'll give it another try. Thanks Marshian

+ Reply to Thread

Similar Threads

  1. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  2. PHP mail()
    By banzap in forum Free Hosting
    Replies: 3
    Last Post: 03-12-2008, 08:35 PM
  3. mail() disabled w/ php v2
    By greenie in forum Free Hosting
    Replies: 1
    Last Post: 11-02-2007, 09:06 PM
  4. php mail function not working
    By aenman in forum Free Hosting
    Replies: 1
    Last Post: 10-26-2007, 11:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers