Jump to content


Photo

PHP.ini and IMAP


  • Please log in to reply
6 replies to this topic

#1 barryman9000

barryman9000
  • New Members
  • Pip
  • Newbie
  • 5 posts
  • LocationSanta Barbara, CA

Posted 14 March 2006 - 04:58 PM

Yes, I'm newer to PHP and I just took over a site that someone else built. That being said, we keep getting an error when trying to send emails:
mail(): Failed to connect to mailserver at "localhost" port 25...

If I make changes to the php.ini, like changing
-SMTP
-SMTP_Port:
-sendmail_from
the error doesn't change. I've tried setting those to our IMAP server (imap.domain.com), localhost, or I've commented them all out, but still get the same error. I've also made sure to un-comment the extension for the IMAP dll, and I've completely turned off IIS6.

Any help is greatly appreciated.

Apache2
the newest PHP
Win2003



#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 14 March 2006 - 05:34 PM

Did you restart Apache after editing the php.ini file?

Ken

#3 barryman9000

barryman9000
  • New Members
  • Pip
  • Newbie
  • 5 posts
  • LocationSanta Barbara, CA

Posted 14 March 2006 - 05:40 PM

[!--quoteo(post=354956:date=Mar 14 2006, 12:34 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 14 2006, 12:34 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Did you restart Apache after editing the php.ini file?

Ken
[/quote]


Yes, everytime.

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 14 March 2006 - 06:13 PM

If you have an imap server installed and have the imap extensions enabled in php. Then you'll want to use the [a href=\"http://uk.php.net/manual/en/function.imap-mail.php\" target=\"_blank\"]imap_mail[/a] function rather the mail function. As the mail function is only limited to SMTP email servers only.

#5 barryman9000

barryman9000
  • New Members
  • Pip
  • Newbie
  • 5 posts
  • LocationSanta Barbara, CA

Posted 14 March 2006 - 06:26 PM

OK, that makes sense. Can I just change the mail() function to imap_mail()? For some reason, I'm guessing it's going to be more complex than that:

mail($_SESSION['member_Email'][$i], $subject, $message, "From: " . $_POST['From']);
}

Also, would these be the correct settings on the php.ini?
; For Win32 only.
SMTP = imap.domain.com
smtp_port = 25

; For Win32 only.
sendmail_from = imap.domain.com

Since the 'From' portion of the email will be different, depending on who has logged in (login uses an email address, and a password). Or can I just use a generic email address in the .ini?

I'm such a rookie... Thanks for your help

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 14 March 2006 - 06:47 PM

Imap doesn't have any configuration settings in the php.ini but to send an email you first have to connect to an Imap mailbox using [a href=\"http://uk2.php.net/manual/en/function.imap-open.php\" target=\"_blank\"]imap_open[/a] once you have connected to the mailbox you should be able to use all the various imap_* functions found on the left hand side on the linked paged above.



#7 barryman9000

barryman9000
  • New Members
  • Pip
  • Newbie
  • 5 posts
  • LocationSanta Barbara, CA

Posted 15 March 2006 - 05:11 PM

I copied this script from the PHP site, where domain is the domain that hosts the imap server. I left out username and password, because it's going to be different every time, depending on who logged into the site. That's also where I'm getting the "From" address:

$id = trim($_GET['id']);
$mbox = imap_open ("{imap.domain.com:110/pop3}INBOX", "", "");

$body = imap_body($mbox,$id,$subject, $message, "From: " . $_POST['From']);
print"<font face=\"verdana\" size=\"2\">$body</a>";
imap_close($mbox);

I got the error "Call to undefined function: imap_open() in C:\Program Files..."

Any ideas why?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users