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
Related
I have a server with a webapp and a mail server (who use sendmail to route mails).
We need to migrate the webapp to an auto-scaling schema, so, I can't have the mail server in there, so, I'm thinking on leaving the mail server right where it is now.
So, to send mails I have different alternatives, I don't want to migrate to an external provider, the costs are to high (like 100 usd/m for mails + dedicated IP).
I'm looking for a way to connect my webapp PHP mail sending classes to this external server with sendmail.
Is there any way I can achieve this without creating my own API to send mails?
On Windows-servers you can change SMTP in php.ini.
Also, you can try to setup relayhost through Postfix (example here), but it seems like a simple API is the easiest and right solution :)
I'm trying to get an in-house bugtracking software up and running. Most of them are written in PHP, which our live server isn't set up for, and the ASPX trackers I've found won't work either, because our live server is running decade-old installs of its server software and upgrading it breaks two other sites we host for clients.
So I've been turning an old rendering machine (Windows XP) into a intranet server I can throw in the basement. I'd install Linux...if a) reinstalling an OS wasn't a full-day job and b) if anyone in the office was actually familiar with Linux
Anyway. I've got WAMP installed and working just fine (one minor issue that the "put on/offline menu item doesn't work, but I can manually change the configs) and Mantis is set up and ready to go, except for one thing.
Mantis can't send emails.
I've tried literally a dozen different ways of doing things: using gmail, using our own relay server, using a "fake" sendmail thing, and various config options between Mantis, PHP, and sendmail.
Nothing works and I am given remarkably little feedback on where the operation is failing.
Is there something I'm missing? I had one person suggest that I needed to install Window's SMTP service (I will need to dig up and/or burn a Windows XP disc). Only one guide mentioned enabling PHP's OpenSSL (but didn't say if that needed to be configured or how).
You might use "fake sendmail".
Most people use this tool to write emails to disk for testing purposes, but
the tool allows forwarding of emails to your SMTP server.
Download: http://www.glob.com.au/sendmail/sendmail.zip
Configure fake sendmail in "sendmail.ini" to contain your SMTP credentials
test sendmail on the CLI and check your SMTP account for outgoing mails
Configure php.ini (directive "sendmail_path")
sendmail_path = "sendmail.exe -t"
test mail() function from a PHP script
Config Files:
sendmail.ini:
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=****#gmail.com
auth_password=*******
force_sender=****#gmail.com
php.ini:
sendmail_path = "\"C:\sendmail\sendmail.exe\" -t"
As it tuns out, my problem was resolved by simply using a different relay server. For some reason Verizon decided to just "nope" without saying why (not that PHP gets much in the way of error messages with email anyway).
http://mandrill.com/ offers a free SMTP service (for the first 12,000 emails per month you send) and as soon as I started using it, bam, everything worked.
I didn't need sendmail (using PHP_SMTP not PHP_SENDMAIL or PHP_MAIL in my MantisBT options) although may be required for other people.
I am making a web application (html + php + apache + mysql) which is on a Debian server, but when I try to send any mail using the php mail function, it is not simply sent me and throws an error. I guess I should install some smtp mail service. What do you recommend that is easy for a novice user settings?
I install a library called sendmail in localhost that simulates that smpt service in WAMP server, but when I upload the code to the production server simply does not send mail.
I researched on some mail servers like postfix, but the information I get is confusing to me. I want to recommend me some effective guide, or any server that is easy to configure for a novice user in the subject.
sorry if the question is obvious, but I want effective information
For sending a mail you just simply need a smtp client that sends a mail to a destination. You don't need to install any smtp server for just sending a mail.
A smtp server is for receiving mails( and other stuff about mails).
All you need to make php sending a mail is to install a smtp client like sendmail
then edit php.ini to be like this:
sendmail_path= sendmail -t -i
EDIT: I guess debian has sendmail by default.
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.
I have a debian webserver and it is running shopsite and some php programs. Which use sendmail to send out email to customers. So this server only needs to send email out. So how do I setup sendmail to use Google Apps smtp? Because I am getting the following error: sm-mta stat=Deferred: Connection reset by mx4.hotmail.com
If you haven't gotten it set up yet, the easiest way to do it is ditch sendmail, install postfix, and then set up the Google Apps SMTP server as your smarthost. IIRC, the default postfix config has a fully-commented config file, so you just need to read through it, uncomment the smart host line, put in the Google SMTP server, and you're done.
Otherwise, you still need to set up Google Apps as your smarthost. There's a ton of Google-able info on how to do this; see here for instance.
You cannot make Google your MTA, as far as I know.
Try using sSMTP