Jump to content

Archived

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

barryman9000

PHP.ini and IMAP

Recommended Posts

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

Share this post


Link to post
Share on other sites
Did you restart Apache after editing the php.ini file?

Ken

Share this post


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

Ken
[/quote]


Yes, everytime.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

×

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.