sendmail.ini

Discussion in 'Web Design and Development' started by Not Available, Sep 6, 2009.

  1. Joined:
    Jun 30, 2009
    #1
    I've been struggling with this for a long time, and I can't seem to find an answer.

    The thing is that I've enabled the mailserver, I can send mails with the mail() function, but they're being sent from _www@internetID, and both Yahoo! and Gmail are blocking messages sent from my IP address, to my annoyance.

    So the question would be, where do I find the sendmail.ini, or its equivalent in Mac OS X if it's named differently than it is in Windows, so that I can use my Gmail account when sending mails?

    Thanks in advance!
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    Did a quick (relatively speaking) search on my machine for sendmail.* and didn't find that specific file. I did come across some sendmail files though in my web directory. I had been downloading some PEAR modules and it included sendmail. Sendmail wasn't there by default and MAMP for whatever reason doesn't include it either. You'll likely need to download the PEAR::Mail package manually. It may have some dependencies you need to download as well. I remember it being a pain.
     
  3. Not Available thread starter Guest

    Joined:
    Jun 30, 2009
    #3
    Well... it's very stupid the fact that apparently, you can't search through hidden files, even if you enable them. I know where sendmail is located, but if you open it up as a text file, it makes no sense (I think it's machine code). I also found some other files, but none of them were relevant.

    I'm also using MAMP, and I think I'll look into PEAR::Mail. Thanks for your response!
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    Just a quick note of how I did my search. From Terminal,

    Code:
    sudo find / -name "sendmail.*"
    It takes a while to run and searches other volumes as well, which could definitely increase the time it takes. It does look at hidden files as well though.
     
  5. Not Available thread starter Guest

    Joined:
    Jun 30, 2009
    #5
    Now I'm trying to send using PEAR::Mail. I installed PEAR under htdocs. Everything seemed fine. Then I edited php.ini, and added the path of the PEAR implementation. Now that's how my php.ini looks, on a MAMP installation.

    Code:
    ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
    sendmail_path = /usr/sbin/sendmail -t -i
    Code:
    ; UNIX: "/path1:/path2"  
    include_path = ".:/Applications/MAMP/bin/php5/lib/php:/Applications/MAMP/htdocs/PEAR"
    I don't know what else I need to do in order to get the SMTP authentication to work. Here's PEAR's sendmail.php, followed by smtp.php
    Code:
    var $sendmail_path = '/usr/sbin/sendmail';
    var $sendmail_args = '-t -i';
    Code:
    var $host = 'smtp.gmail.com';
    var $port = 465;
    var $auth = true;
    var $username = 'my_gmail_address';
    var $password = 'my_gmail_password';
    Last but not least, here's the part of the script which sends the mail
    Code:
    include('/Applications/MAMP/htdocs/PEAR/Mail.php');
    
    $recipients = $to;
    
    $headers['MIME-Version'] = '1.0';
    $headers['Content-type'] = 'text/html; charset=iso-8859-1';
    $headers['From'] = 'my_gmail_address';
    $headers['To'] = $to;
    $headers['Subject'] = $subject;
    $headers['Cc'] = $cc;
    $headers['Bcc'] = $bcc;
    
    $body = $text;
    
    $params['sendmail_path'] = '/usr/sbin/sendmail -t -i';
    
    // Create the mail object using the Mail::factory method
    $mail_object =& Mail::factory('smtp', $params);
    
    $mail_object->send($recipients, $headers, $body);
    
    // Display a confirmation message
    echo "The message has been successfully sent";
    What am I doing wrong?
     
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    Are you getting any errors? I'm not sure if the below line has a typo, the =& in it. I'm not familiar with that syntax.
    PHP:
    $mail_object =& Mail::factory('smtp'$params);
    I don't currently have things setup to use sendmail through the Pear stuff. It was something I use to use when I hosted my site through my home. So I'm just working from memory. I remember, from home, I needed to use my ISP's SMTP servers to send out emails because they required it. I made the modifications in the php.ini file, though that was on a Windows machine and may not apply here, but you may need to alter the host you're using.

    This article has a decent quick example for usage. Notably is shows how to check for errors after sending the email.
     
  7. Not Available thread starter Guest

    Joined:
    Jun 30, 2009
    #7
    We were looking at the same article. The thing is that my PHP is still in its infancy, so classes and object-oriented PHP is still rocket science for me :)

    I'm going to try a number of things, but that article does not expose the last version of PEAR::Mail because the SMTP settings are now located in a separated file, smtp.php, in the mail folder.
     

Share This Page