Jump to content

mail function works at the office, but not at home.


Pacopag

Recommended Posts

Hi.

I had some trouble getting the mail function to work, I guess because I'm developing on LAMP (localhost), but I got it working at the office yesterday by configuring things as outlined here

 

http://mattsk.blogspot.com/2010/09/configure-lamp-on-ubuntu-1004-to-send.html

 

This got it working fine.  But today I'm trying it from home and it's not working (mail is not getting sent).  I don't know how the network is set up at work, but at home I'm on wireless lan through a d-link router.  I have a feeling it has something to do with the smtp_port = 465 (see link above), and that port maybe being blocked by the firewall or something.  I'm not really sure how all this stuff works though.  I tried contacting d-link, but they want some money before they'll help me out.  I followed some instructions I found online to forward port 465, which seemed to work (at lease the router told me so).  But the mail is still not sending.  A also tried the "fix-almost-any-computer-problem-ever" solution (i.e. I restarted my computer).  But still nothing.

 

I hope I've come to the right place for help.  Any help would be great.

Thanks.

That didn't work. In the link I used to get mail to work at the office, it says that it's using the Gmail SMTP server to send mail from localhost.  I don't know if that's why he used 465.

 

I would think that sending mail from LAMP localhost is pretty common.  Is there some standard way to set things up so that localhost can send mail?

 

Thanks for your help.  I have to step out for about 20 min, so I apologize if I don't reply to the next post promptly.

So I installed dovecot-postfix, but mail() is still not working.  I tried changing

smtp_port = 465  to smtp_port = 25.

And also tried commenting this line out completely from the php.ini file.

Also, from what I read, postfix doesn't use sendmail, so maybe I need to change the line

sendmail_path = /usr/sbin/sendmail -t

in php.ini to something else?

 

Can anyone tell me how to configure php to jive with postfix, or maybe a useful link?  Google returns lots of stuff, but the config instructions are hundreds of lines long.  I'm hoping that in reality it's just change a couple lines here or there in a few files.

 

Also, I tried putting everything the way it was when it was working at the office.  Then I bypassed the router (plugged straight into the modem), and it still didn't work.  So my original theory about the port being blocked is squashed.  I guess I gotta get postfix working.

After a whole day of try..fail..try...fail...and so on, I gave up on postfix.  I found a working solution that uses PEAR at

 

http://stackoverflow.com/questions/712392/send-email-using-gmail-smtp-server-from-php-page

 

Installed PEAR and tried the code at the link above and it worked.  Here is the working code (had to fix one small error pointed out in a later post)

 

<?php

 

      require_once "Mail.php";

 

        $from = "<[email protected]>";

        $to = "<[email protected]>";

        $subject = "Hi!";

        $body = "Hi,\n\nHow are you?";

 

        $host = "ssl://smtp.gmail.com";

        $port = "465";

        $username = "[email protected]";

        $password = "password";

 

        $headers = array ('From' => $from,

          'To' => $to,

          'Subject' => $subject);

        $smtp = Mail::factory('smtp',

          array ('host' => $host,

            'port' => $port,

            'auth' => true,

            'username' => $username,

            'password' => $password));

 

        $mail = $smtp->send($to, $headers, $body);

 

        if (PEAR::isError($mail)) {

          echo("<p>" . $mail->getMessage() . "</p>");

        } else {

          echo("<p>Message successfully sent!</p>");

        }

 

    ?>  <!-- end of php tag-->

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.