Jump to content

PHP.ini and IMAP


barryman9000

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

Link to comment
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.
Link to comment
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.
Link to comment
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
Link to comment
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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.