1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

set email SENDER

Discussion in 'PHP' started by roice, Jul 12, 2011.

  1. #1
    hello
    when my system send email to my clients they get it with the title that I set. how do I set the SENDER?
    for now its look like that:


    Here are my properties:
    
    							$from= "MIME-Version: 1.0 \r\n";
    							$from.= "Content-type: text/html; charset=windows-1255 \r\n";
    							$from .= "From: $sender \r\n";							
    
    							$sender= $site_name;
    							$subject= 'New Reply in ticket title - '.$title;
    							$message = "some text"
    							mail($site_email, $subject, nl2br($message), $from); 
    
    PHP:
    Im using PHP
    Thank you in advanced
     
    roice, Jul 12, 2011 IP
  2. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    PHP read left to right, top to bottom. If you're setting a variable after it's called, it can't use it. Move the $sender = above the 'From: $sender" statement.
     
    ntomsheck, Jul 13, 2011 IP
  3. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I forgot to write it but I already did it - nothing change :/
     
    roice, Jul 13, 2011 IP
  4. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #4
    Can you rephrase your question? What title is being sent? Do you mean this?

    $sender= $site_name;
    PHP:
     
    BRUm, Jul 14, 2011 IP
  5. soniasyril

    soniasyril Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It should be mail(to, subject, message, headers)
    
    //remove $from .= "From: $sender .....
    //change to $sender = "From: $sender \r\n";
    
    PHP:
     
    soniasyril, Jul 15, 2011 IP
  6. spletnisistemi

    spletnisistemi Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Maybe it would be easier if you would use htmlMimeMail.

    $m = new htmlMimeMail();
    $m->setHTMLCharset ("UTF-8");
    $m->setHeadCharset ("UTF-8");
    $m->setTextCharset ("UTF-8");
    $m->setSubject ($subject);
    $m->setHtml ($body);
    $m->setFrom ('your@email.si');

    It's way eaiser then creating and concating together proper headers.
     
    spletnisistemi, Jul 15, 2011 IP
  7. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ok, and what should I do with variable $m after I set all parameters?
     
    roice, Jul 17, 2011 IP
  8. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #8
    You would need to execute the object once the parameters are set:

    $m->send();
    PHP:
    PHP has automatic garbage collection so you need not do anything with the object after this point, however if you want to dispose of it you can set it to null or use unset()
     
    BRUm, Jul 17, 2011 IP
  9. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    OK, I tried it and giot this error:

    Fatal error: Class 'htmlMimeMail' not found in /home/pelegisr/public_html/sites/submit_tkt.php on line 224



    line 224 is: $m = new htmlMimeMail();

    why is that?
     
    roice, Jul 18, 2011 IP
  10. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #10
    You don't have the class present as you don't have the library. This is not a core library within PHP, it's a third party's.
     
    BRUm, Jul 18, 2011 IP
  11. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    is it something that I need to ask from my server admin?
     
    roice, Jul 19, 2011 IP
  12. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #12
    If you don't have access to the root PHP install directory, yes :)
     
    BRUm, Jul 19, 2011 IP