You are not logged in.

#1 2013-12-15 23:02:36

wolfdogg
Member
From: Portland, OR, USA
Registered: 2011-05-21
Posts: 545

configure LAMP stack to use internal mail relay without....

Does anybody know of a way i can configure my new LAMP stack to use the companys internal mail relay without having to implement postfix, or sendmail?  I did already try to implement send mail recently, and its very confusing to me since i have never set up a mail server, and i tried to implement postfix, SOHO i think was the wiki i used, and that never got done either.  It seems incredibly cryptic to someone who even has tons of server experience, just not the email portion.  Maybe the wikis are just written for those who have more experience in making SSL certs, and being more versed in MX records, and DNS for email specific things.  etc... 

Since i have not successfully set up a mail server thus far, i dont have enough general mailer / experience to understand the wikis on setting up Sendmail, etc...   

My company asked me if i could just use their internal mail relay instead.  I would like to know if i still need to set up sendmail to allow PHP mail() function to send out mail, or if theres some configuration somewhere that i can adjust so it can use the existing internal mail relays. 

Note, the only thing im trying to achieve here is to get my apps to send out emails for login password management, and error logs.


Node.js, PHP Software Architect and Engineer (Full-Stack/DevOps)
GitHub  | LinkedIn

Offline

#2 2013-12-16 10:01:13

satanselbow
Member
Registered: 2011-06-15
Posts: 538

Re: configure LAMP stack to use internal mail relay without....

If you are using PHP for scripting have a look at either http://swiftmailer.org/ or http://pear.php.net/packages.php?catpid=14&catname=Mail. The php mail() function is very feature limited and prone to failure without any sane error reporting system. You can specify a default SMTP server in your php.ini although this solution is pretty redundant due to flaky authentication handling.

Offline

#3 2013-12-16 17:09:54

wolfdogg
Member
From: Portland, OR, USA
Registered: 2011-05-21
Posts: 545

Re: configure LAMP stack to use internal mail relay without....

ahh, i see. so your saying like on this page for examplehttp://pear.php.net/manual/en/package.mail.mail.php#13632 to specify smtp server?  Looks like that might be all need to do....  hmm, food for though.    i have used pear mail alot.  I didnt know you could set   up params using the factory like that.

Is this the way most devs do this, instead of installing postfix for example, when they just need email functionality in PHP?

Edit: I am implementing swift mailer due to the constant problems pear has with upgrading php.  However, I just remembered something.  How can i use swiftmailer for cron jobs?  I was trying implement not only mail functionality for my web apps, but also for cron jobs.   Do i need to just create a php script and somehow pass cron errors through it?  Or is there some built in features in cron that i can just point it to swiftmailer or something?

Last edited by wolfdogg (2013-12-16 19:33:08)


Node.js, PHP Software Architect and Engineer (Full-Stack/DevOps)
GitHub  | LinkedIn

Offline

#4 2013-12-17 09:43:07

satanselbow
Member
Registered: 2011-06-15
Posts: 538

Re: configure LAMP stack to use internal mail relay without....

In my experience an SMTP server is preferable to sendmail/postfix as it is far more portable and robust... (in a web environment) many webhosts, for example, pay no heed to the configuration of sendmail - so code that runs on one host fails on another. PHP mail() can be leveraged to use any backend you like but this typically requires root access (or at least permissions beyond those offered on typical hosting services), and, as said above, does not allow for any useful level of error reporting.

Swiftmailer is (generally) my weapon of choice - unless the particular project has additional PEAR dependencies/requirements that mean it makes sense to stay within the same codebase... not that it (PEAR) is always that consistent anyhow wink

I can't really offer much in the way of help with cron integration as that is not a route I have taken - it should think it would be pretty trivial (sic )to implement as you build your script... swiftmailer has some pretty neat "live address" checking routines - have a dig through the docs wink

Last edited by satanselbow (2013-12-17 09:49:13)

Offline

#5 2013-12-17 10:38:14

progandy
Member
Registered: 2012-05-17
Posts: 5,280

Re: configure LAMP stack to use internal mail relay without....

AFAIK cron always sends reports with sendmail. If you don't want a local mailserver, there are some sendmail implementations that connect to an smtp server and send the mail to it. To get a bit security, give the smtp password only in a user configuration file.
https://wiki.archlinux.org/index.php/Msmtp
Edit: If you run a php script that sends mails, you can use swiftmailer just like the website.

Last edited by progandy (2013-12-17 10:41:36)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#6 2013-12-17 23:39:47

wolfdogg
Member
From: Portland, OR, USA
Registered: 2011-05-21
Posts: 545

Re: configure LAMP stack to use internal mail relay without....

i want a local mailserver, i just cant figure out how to set one up.    ok, so my scripts can use swiftmailer, through the relay, but if i want cron emails i have to have sendmail, or something like Msmtp?


Node.js, PHP Software Architect and Engineer (Full-Stack/DevOps)
GitHub  | LinkedIn

Offline

#7 2013-12-20 01:51:51

wolfdogg
Member
From: Portland, OR, USA
Registered: 2011-05-21
Posts: 545

Re: configure LAMP stack to use internal mail relay without....

i figured out two of my main problems so far, it was as easy as pointing the php.ini configuration to the smtp server, and for one of th eapplications, it was as simple as changing the setting to use SMTP in the config, and adding the smtp server address, it was trying to use phpmail.

so far i havent had to install any mail server.  but dooms day is coming, since i have to get the cron job mail working.      what kind of sendmail implementations are out there for arch, so i can just point it to use my shared hosting smtp server?


Node.js, PHP Software Architect and Engineer (Full-Stack/DevOps)
GitHub  | LinkedIn

Offline

#8 2013-12-20 02:29:09

progandy
Member
Registered: 2012-05-17
Posts: 5,280

Re: configure LAMP stack to use internal mail relay without....

wolfdogg wrote:

so far i havent had to install any mail server.  but dooms day is coming, since i have to get the cron job mail working.      what kind of sendmail implementations are out there for arch, so i can just point it to use my shared hosting smtp server?

Here is a list, some a mailservers others are smtp-sendmail implementations.

$ pkgfile -b sendmail                 
extra/msmtp-mta
extra/postfix
extra/ssmtp
community/esmtp
community/exim
community/opensmtpd

| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#9 2013-12-20 11:19:39

dschrute
Member
From: NJ, USA
Registered: 2007-04-09
Posts: 183

Re: configure LAMP stack to use internal mail relay without....

Maybe look at something like nullmailer. It's designed specifically for when you need to send small amounts of messages out ( I.E. via cron ) but don't want/need a full blown smtp server. There are other similar programs as well, but this is one I've used with success in the past.

Offline

#10 2015-07-24 06:04:54

wolfdogg
Member
From: Portland, OR, USA
Registered: 2011-05-21
Posts: 545

Re: configure LAMP stack to use internal mail relay without....

hmm, looking back on this, i went with exim, and didnt mention it, thanks to all the help here.  actually i probably mentioned it on another post :-)   Im doing a centos build right now, and was looking for this info, because i couldnt remember lwhat the heck it was called, EXIM! yes.. easy peasy..


Node.js, PHP Software Architect and Engineer (Full-Stack/DevOps)
GitHub  | LinkedIn

Offline

Board footer

Powered by FluxBB