Is it possible to send mail to an exchange server that is running locally on our network using php-apache that is also running in a localhost? If its possible, can anyone point me to the right direction?
Thank You Guys in Advance
The easiest way is to just to install a local MTA like blatmail (assuming you're on Windows; if you're on Linux you have sendmail or an equivalent already and mail() should just work).
That said, assuming your Exchange server will forward without authentication from the local network, set SMTP to the address or hostname of your Exchange server in .ini (or ini_set "SMTP" to that in the script itself).
Note that the vanilla mail() doesn't support authentication, and I'm pretty sure doesn't support TLS.
So you should definitely only use it on a completely trusted network.
Related
I recently setup a CentOS server that I am planning on using just for email. I installed and configured Postfix and sending / receiving messages via command-line is working fine.
I want to be able to send mail to my end-users from a PHP application that is hosted on a separate CentOS server, using the dedicated mail server's Postfix as the MTA. Is this possible? Or do I need to install Postfix on the server where Apache / PHP resides?
If it is possible, how do I go about connecting / relaying the messages that are to be sent?
I am looking for the common conventions / best practices for running my own mail server, so any advice is much appreciated. Thanks!
If you use mail() in PHP, the documentation states that it only uses sendmail on the local machine.
You may, however, setup sendmail to forward mail to your other server, like in this link : http://www.cyberciti.biz/faq/configure-sendmail-as-a-smart-host/
According to that page, you can do this:
Add to /etc/mail/sendmail.mc:
define(`SMART_HOST',`my_smtp_server')
Then restart sendmail. If it still doesn't work, you might need to run:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
or
cd /etc/mail; make
and then restart sendmail.
If you need to fake the server name which sendmail uses, you might add this in sendmail.nc (ref.: https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-email-mta-sendmail.html):
FEATURE(always_add_domain)
FEATURE(`masquerade_entire_domain')
FEATURE(`masquerade_envelope')
FEATURE(`allmasquerade')
MASQUERADE_AS(`my_public_domain.')
MASQUERADE_DOMAIN(`my_public_domain.')
MASQUERADE_AS(my_public_domain)
You can configure postfix as MTA on the same server on which php/apache resides if you keep it remote you have to ensure proper connectivity to MTA and due to any timeout issue your mails might not get delivered. So you can run postfix on the local apache/php server and configure it's settings with php to send email.
http://email.about.com/od/emailprogrammingtips/qt/How_to_Send_Email_from_a_PHP_Script.htm
The above link would be helpful.
Thanks & Regards,
Alok Thaker
I'm looking for an SMTP server that I can setup on a windows machine:
It needs to be lightweight, not loads of security settings
I only need to send email not receive it
Its needs to be able to send email from anonymous users
The reason is that I've installed Apache and PHP on a windows machine and want an SMTP server to route mails through, I plan on using this windows sendmail.exe which I have used before and works great.
Last time I did this I used sendmail.exe and Stunnel and used a gmail address, but I can't do that this time, needs to be sent from localhost.
You could use the SMTP server integrated in IIS, you could also go for smaller mail servers like http://www.xmailserver.org/ or http://www.mailenable.com/
Too bad, stunnel/gmail is great and I've used it a ton for test environments.
Two great alternatives are to install exim via Cygwin, or to use IIS as an SMTP server.
I have personally used the first with success. I have never tried IIS although I know this is a viable solution for some.
I'm building a site on my home computer using MAMP. The code I'm using employs the PHP mail() function to send emails, but whenever I test it, the mails aren't getting sent.
My computer is connected to the net, but I'm wondering if there's something about local hosting that prevents mails from getting sent. I'm not getting any kind of error message.
Any ideas?
PHP can send mail in one of two ways.
The first, and the default on non-Windows systems, is to use the local mail transfer agent installed on the system. This would be "sendmail" or an application compatible with it, the most popular probably being postfix.
The other is to connect via SMTP to some mail server.
You will either need to install a mail transfer agent on your local system (and set it up correctly), or edit PHP's configuration to specify an SMTP server address and port.
Yes, there are things that could block locally hosted mail. For one, your ISP could block SMTP to servers other than the ISP. ask your ISP support if they block SMTP... Or try telexing so someone's MX port 25 and do you get a response?
If your ISP blocks smtp you can still send the mail, but first you must relay that email through a hosted email server like your ISP mail server. This process is called 'smart hosting' and you can search for more info.
Even if you are not blocked on port 25, many sites will refuse or lose smtp traffic that originates from a dynamic or residential IP address, so again the smart host suggestion.
Also I suggest not using the built in mail() function in PHP... Use something that replaces and improves it like http://pear.php.net/package/Mail or http://sourceforge.net/projects/phpmailer/. Again, use the SMTP method as it is way more reliable than direct sending or calling Sendmail.
It is important to confirm this problem, doing SMTP manually over telnet. That way you isolate the problem from PHP. I did ISP support for years and saw this question lots. Most people setup php and mail correctly but get stuck on a background network issue with SMTP.
If you have Wireshark installed, it can record network traffic and you might see the actual SMTP traffic, for example the remote server may be refusing your connection. Wireshark is helpful but not required to solve this though. Good luck.
You need to setup SMTP server in order to be able use mail function, or you can use PHPMailer class, with it you can avoid using mail function and setup problems, PHPMailler need socket extension to be loaded in order to function correctly.
I realize that I need to use a mailserver so people can contact me, my question is, how can I set one up on my local machine so I can test it?
I have XAMPP installed with PHPMyAdmin and I'm just toying and learning with it.
Now, in my PRODUCTION server, what email should I use to send users comments to me? I'm really new and need some guidance.
Generally I don't recommend you setting up a mailserver on your local machine just for testing.
Check out the PHP function mail(), it should be already configured and ready to run on the production server.
If you want to test if your script works, simply print out the arguments you would pass to mail().
Assuming your production server is running linux, you can use the sendmail binary or local smtp.
I'd like to test password recovery and similar email related features for a website.
I'm using PHP (cakePHP framework) and the syntax seems easy enough but I'm unsure of the email server setup.
I've looked around for a good tutorial but they aren't specific enough.
What is a quick and easy mail server to use locally? also... some initial steps to start up would be appreciated.
Test Mail Server Tool
xampp comes with a smtp server for sending mails from localhost, check out http://www.apachefriends.org
I've had good success with SMTP4DEV on a Windows box. It is open source.
You can see recent messages fairly easily with this tool. All it requires is that in your application you use localhost as the SMTP server.
From what I remember PHP has a config file has a entry for the SMTP server. You can get a local SMTP server and point ini for PHP to localhost.
On Windows Microsft Internet Information Server would have SMTP, I think even client will have an SMTP relay (may not be a full server however). or I am sure you can find numeros free SMTP server.
You could look at Post Case although I don't believe it is now (currently) free - it used to be, or you could look at Hamster 2.1 which is free, and then there is hMailServer 5.x.