SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php function: mail will not send emails

    I can not get the php function: mail to actually send me mail.

    <?php
    $to = 'nobody@example.com';
    $subject = 'the subject';
    $message = 'hello';
    $headers = 'From: webmaster@example.com';
    mail($to, $subject, $message, $headers);
    ?>
    Is there something missing or need programmed into "php.ini" for the email to work?

  2. #2
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you have to set smtp port and smtp host in php.ini file

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do you set the SMTP port and host in the php.ini?

  4. #4
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    open php.ini file,find smtp port set 25 and smtp host is yours host like this example.com

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The port setting was right. I did not have to change it: "smtp_port = 25".

    I tried: webmaster@example.com and just: example.com. Neither of which worked.

    What is it exactly do I write into "SMTP =" in the php.ini?

  6. #6
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    write your host name ,i have given jus example.

    SMTP = yoursite.net (which is your host name put that here)

  7. #7
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have MSN Hotmail. My email is name@live.com.

    I tried putting "stmp.live.com" my incoming smtp mail from server that did not work.

    Could you give some other examples of what works?

    Or do you have to do something to the php.ini to initialize the new settings?

  8. #8
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

  9. #9
    SitePoint Member
    Join Date
    Oct 2008
    Location
    Rotonda West, Florida
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For what it's worth, I have found that some hosting providers only support the PHP mail function on UNIX servers.

  10. #10
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have Apache version 2.2.21 but I have never used it.

    How do I restart the apache server so that PHP modules and attributes from php.ini will be reloaded.

  11. #11
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    r u using xammp?

  12. #12
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the help. I just needed to configure the php.ini with the correct "SMTP=smtp.mail.com" with a matching "smtp_port =25" and it works.


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
  •