Using Sendmail in PHP

Discussion in 'PHP' started by pradeep, Oct 14, 2005.

  1. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    All PHP coders are aware of the mail() function in PHP, which can be used to send mails. On Linux systems we ussually have Sendmail program installed, if someone is facing a problem sending mails with mail() function, they can alternatively use Sendmail to send mails.
    For sending mails using Sendmail we need to open a pipe to the sendmail program, which can be accomplished using the popen() function in php.

    Example:
    PHP:
        $fd popen("/usr/sbin/sendmail -t","w") or die("Couldn't Open Sendmail");
        
    fputs($fd"To: recipient@hisdomain.com \n");
        
    fputs($fd"From: \"Your Name\" <youremail@yourdomain.com> \n");
        
    fputs($fd"Subject: Test message from my web site \n");
        
    fputs($fd"X-Mailer: PHP3 \n\n");
        
    fputs($fd"Testing. \n");
        
    pclose($fd);
     
  2. dj_buddhika

    dj_buddhika New Member

    Joined:
    Dec 7, 2006
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    do you know this is cannot send emails to hotmail or yahoo accounts.
    How to make it success
     
  3. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
  4. manilodisan

    manilodisan New Member

    Joined:
    Dec 10, 2006
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    hotmail, aol and some others have huge problems in receiving the emails due to their spam filters. I would recommend sending emails via SMTP
     
  5. manilodisan

    manilodisan New Member

    Joined:
    Dec 10, 2006
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Or...a fresh IP of the server :))
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice