Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I send a simple email when a PHP form has been updated?

Status
Not open for further replies.

mvital

Technical User
Jul 2, 2003
128
US
Hello All,

Someone generated forms using PHP so they are on a website. The forms are updated via the website and Access tables are populated.

Is there a way that I could fire off an e-mail to people when the PHP form has been updated? This is a dispatch scenario. A complaint comes in the form is filled out. A very simple e-mail, nothing fancy, maybe just in the subject line that "a new complaint has been recorded" so that the people receiving the e-mail are aware and that one of them responds to the complaint.

It sounds like the PHP route has issues. My collegue said that The mail() protocol is not well supported in windows and we are having issues routing mail through the exchange server.)

I am posting the issue, but only had part in developing the Access database.

Any help or guidance on how to generate this simple e-mail from the PHP form would be greatly appreciated.

thank you in advance,

MV
 
This is very easy but first who says the mail() protocol is not well supported in windows? I am on a windows server and have no problems with it at all. 4 years and no probs. You must make sure that the email you are sending to (or sending from) resides on the server b/c your server probably doesn't relay email (in effort to combat spam). That's probably why it doesn't work in some cases but that's not a php issue it's a mail server one.

Anyway, here is your code:

Code:
<?php

$to = "email address to send to";
$subject = "this is the subject";
$body = "this is the body";
$headers = "From: Name <Email address>\n";

mail ($to, $subject, $body, $headers);

?>

Hope this helps!

NATE


Got a question? Search G O O G L E first.
 
Routing mails through an exchange server can be a nightmare. I think (but can't say that I'm absolutely sure) that the mail() function uses the SMTP protocol which is on TCP port 25.

Now, at my work, I can't send mails out of the LAN with the mail() function.

It's got to do with the firewall.

I think (again, not 100% sure) that Exchange is using the IMAP protocol which is on TCP port 143.

I'm not sure how to send IMAP mails with PHP. But I'd be glad to know if someone know howto ;-)

Good luck
 
exchange sends and receives mails using an smtp server. often this is on the same box as the exchange server itself, but it does not need to be. a virtual smtp server can be created as part of the exchange install. if you use mail() and point it at an smtp/exchange hybrid server, it does not touch the exchange server. just the smtp component of it. for example, the mail will not appear in the sent-items folder of a client just because it uses the same server address as the exchange client. for this to happen you need to execute a separate imap call and place the mail item in the appropriate folder store.

clients interact with exchange using a series of protocols that have nothing to do with smtp. a client might use imap4 but more often than not the client is outlook and uses its own bespoke protocol. if a client is configured to use imap4 or pop3 it will actually send outgoing messages to the exchange server using smtp and the exchange server will then relay them (depending on permissions).

mail() works just fine in windows. i have been using it for many years on both both win2003 and winXP boxes. typically i set up a single smtp server to receive the calls from mail() but on occasion i have also used the smtp server on a winxp box (for example if i am travelling). this is available in the add/remove windows components dialog, then edit php.ini to point to localhost rather than your main smtp server.

as for whether your smtp server accepts mail from internal clients - that's a matter for your IT administrator. it's the work of seconds to enable it, if permitted.
 
One note on mail()

When I send mails with PHP/mail() through my web hosting provider, I have to specify a valid from/sender e-mail address. Otherwise the server locks me out for the next five minutes (security to avoid spamming).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top