PDA

View Full Version : [ubuntu] mail from webserver question


johan.alfa
August 12th, 2008, 06:29 AM
Hello all,

Before I was using xampp.
Now I set up a lamp ssh ubuntu server.

I would like to send mail from some web pages.
I don't need mail read or advanced mail stuff.

In xampp I could change php.ini smpt and everthing worked fine.
Xammp used then my ISP smtp server.
How can I simulate this with ubuntu.

greetings,

dperfors
August 12th, 2008, 07:19 AM
The same way, just change the /etc/php.ini

johan.alfa
August 12th, 2008, 07:25 AM
Don't I have to install sendmail or something like postfix?
I thought the smtp setting in php.ini was windows only.

greetings,

hyper_ch
August 12th, 2008, 07:34 AM
yes, you need a MTA... sendmail or postfix could be working. Not sure if you can set in the php.ini to actually relay email to another server.

dperfors
August 12th, 2008, 07:36 AM
I thought this was possiblem but I am not 100% sure..

hyper_ch
August 12th, 2008, 07:37 AM
I think it is - but I never was in such a situation where I needed to do it ;)

windependence
August 12th, 2008, 07:38 AM
Don't I have to install sendmail or something like postfix?
I thought the smtp setting in php.ini was windows only.

greetings,

Actually this should work by default since sendmail is installed, but as hyper_ch mentioned Postfix would be much better. You can use the php mail() function.

-Tim

johan.alfa
August 12th, 2008, 07:44 AM
Is sendmail installed?
I only checked lamp and ssh during server install.

When typing sendmail on the command line I get a mention of packages which will install sendmail.

I do not want install software I do not need.

greetings,

windependence
August 12th, 2008, 12:53 PM
Sendmail <should> be installed by defualt on most distros. I would be surprised if it isn't, however if not, don't install it, but install postfix instead, it's much easier to configure and more secure than sendmail.

-Tim

johan.alfa
August 13th, 2008, 04:48 AM
Am I wrong thinking postfix will open a new port on the server?
I would like to send mails.
I do not neet te receive anything.
Is it possible to send mails some way without opening new ports?

Thanks,

gishaust
August 13th, 2008, 07:51 AM
You need to make sure that you have the port open on the firewall on the box that has apache server, postfix and dns( i think). but I have never had the router onto the internet port open for postfix or dns. There is one draw back if you send the email to fred@gmail.com I will turn up in spam. and some isp will block it altogether. Because they can't talk to postfix. but if you are only using it on a form on one or two web sites and you choose the right email address it is fine. I would go gmail

I think from memory you also need dns but it is a while since I did it? if you have a look at some of you old post you will see i asked something similar. Don't laugh to much I was very raw.:wink:

gishaust

MJN
August 13th, 2008, 07:56 AM
I would like to send mails.
I do not neet te receive anything.If you have access to an external mail server, e.g. that of your ISP's, then you might want to check out Nullmailer (http://untroubled.org/nullmailer/) - you'll find it in the repositories. It is a simple outbound-only MTA which will pass mail onto your upstream mail server for onward delivery.

Mathew

johan.alfa
August 13th, 2008, 08:17 AM
Hello,

I could not find Nullmailer in the standard server repos.
Are they in the backport?

greetings,

MJN
August 13th, 2008, 09:08 AM
You should find it in universe.

Mathew

johan.alfa
August 13th, 2008, 10:42 AM
Hello,

Nullmailer is working fine over here.
Only problem I still have is php apche is sending mail as www-data@bla.bla.

Anybody knows how I can change the www-data to something else?

greetings,

MJN
August 13th, 2008, 12:25 PM
The From: address can be specified in your PHP mail function as an additional header - see example #2 at http://uk.php.net/manual/en/function.mail.php

Mathew

windependence
August 13th, 2008, 01:00 PM
You need to make sure that you have the port open on the firewall on the box that has apache server, postfix and dns( i think). but I have never had the router onto the internet port open for postfix or dns. There is one draw back if you send the email to fred@gmail.com I will turn up in spam. and some isp will block it altogether. Because they can't talk to postfix. but if you are only using it on a form on one or two web sites and you choose the right email address it is fine. I would go gmail

I think from memory you also need dns but it is a while since I did it? if you have a look at some of you old post you will see i asked something similar. Don't laugh to much I was very raw.:wink:

gishaust

I see you have an MTA working and that's great!

Just for future reference and for everyone reading this, Postfix can be configured to do exactly the same thing and it's pretty easy.

Gishaust, you do not need a DNS server for sending mail OR for web hosting. For some reason, everyone here thinks you do.

On the gmail thing, it has nothing to do with postfix, it has to do with people setting up "half baked" mail servers. I have postfix running on my formums and we have no problem sending to gmail accounts, BUT I have a static address, and reverse DNS is set up for my domains. What happens is if the gmail mail server cannot resolve your name from the IP it will reject the mail and rightly so. So if you are using some kind of work around like dynamic DNS service, it's not going to work because you don't have a static IP that resolves to your domain, therefore they think it's either being spoofed, or relayed.

Then there are some ISPs like Comcast that don't allow ANY mail to be sent from there IP range (unless you have a business account).

-Tim

johan.alfa
August 13th, 2008, 05:27 PM
Hello all and thanks for helping,

@windependence
I tried postfix and it does indeed the same if installed like a satelite. But I could not make the from address as I wanted.
With null mail I can make it look like www-data@bla.net
But with postfix I had to make it like www-data@bla.bla.net to work. This was one bla to much.
I would like to use postfix or something else but the install is above my head for the moment.

greetings,

gishaust
August 13th, 2008, 05:39 PM
Thanks for the info. This thread has been great learned so much.

MJN
August 13th, 2008, 07:07 PM
I tried postfix and it does indeed the same if installed like a satelite. But I could not make the from address as I wanted.
With null mail I can make it look like www-data@bla.netHave you changed your PHP code now?

Mathew

obscenic
September 21st, 2008, 01:37 AM
Have you changed your PHP code now?

Mathew

This does not work, nullmailer still sends from www-data.
I've been fighting with this all day to no avail. If anyone knows of a solution, I would be extraordinarily grateful.

In my case, my SMTP (example.ca) - auth based SMTP, rejects mail in which from addresses are not from validuser@example.ca

Any thoughts?

obscenic
September 21st, 2008, 01:48 AM
Workaround:

On your SMTP host, create a mail account called www-data...
Stupid, but unless nullmailer comes up with a way to overwrite the from address, there's not really any other solution.