php mail function

Discussion in 'PHP' started by shreder, May 24, 2007.

  1. #1
    Hello.

    My server currently blocks all outgoing mail messages from NOBODY.
    How can i configure my phpmail function to not send out an e-mail from NOBODY so it won't get blocked?

    Thank you!
     
    shreder, May 24, 2007 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    check out www.php.net/mail

    and look at how you can add the senders email address.
     
    sarahk, May 24, 2007 IP
  3. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Why would you send a mail from nobody? I's better to validate the user's input before sending any emails. If you want it to be sent only from one email to all rrcipients, add it to the mail function and everything will be ok.
     
    manilodisan, May 24, 2007 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #4
    manilodisan - if you do a basic mail command with no extras it's up to the webserver who it says the email is from. If you haven't coded in a "from" header then it may well be from nobody. Is this desirable... no! But spammers don't care and that's why the webhosts block it. However this causes problems for newbie programmers.

    FWIW: I use http://phpmailer.sourceforge.net/ to send emails and it's so easy - it does all the hard work for me.
     
    sarahk, May 24, 2007 IP
  5. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It's not desirable but it also means that your code is either incomplete or not safe. Why would I leave the thinking to the server whan I can leave only one door open and that's for the sender who MUST enter a valid email address (preferably a captcha too) before any mail function is executed. Of course, every critique is constructive and you may have a point for some situations that are better avoided. Anyways. Hope something good gets out.
     
    manilodisan, May 24, 2007 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #6
    I think maybe we've read the original post differently.

    My take on the situation was that shreder was sending the emails from a script and that the to email was ok, but that s/he wasn't specifying a from address.

    For instance in a contact form you would be sending the email to yourself with info like name, phone, comment and you wouldn't necessarily give a sender because it's coming from your own website.

    The webserver doesn't know that though and blocks the send (good behaviour) so shreder will need to put the headers in to send a good, fully formed email.
     
    sarahk, May 24, 2007 IP
  7. tinkerbox

    tinkerbox Peon

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It show NOBODY, is either you left sender field empty or incorrect format.
    This format is correct:
    
    mail($email_to, $subject, $body, "From: Your Name <yourname@domain.com>");
    
    PHP:
     
    tinkerbox, May 24, 2007 IP
    sarahk likes this.
  8. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Eh...whatever..a good code will always be a good code. I always specify a sender.
     
    manilodisan, May 24, 2007 IP