Forum Moderators: coopster

Message Too Old, No Replies

problems with php mail()

problems with php mail()

         

hexstar

1:59 am on Mar 19, 2005 (gmt 0)

10+ Year Member



Hello, I'm running a webserver on YellowDog Linux 4.0.1 [yellowdoglinux.com] with Apache 2.0.51, php 4 and mysql but no local mail server....I am hosting some people and they'd like to be able to use the php mail() function...is there a way for me to configure it to send mail through a smtp server without having to rebuild php? if so, how? any help is greatly appreciated.

thanks in advance!

jatar_k

3:55 am on Mar 19, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld hexstar,

I would imagine you have sendmail, conf up sendmail and get it running and the mail function will just work, no rebuilding.

hexstar

4:12 am on Mar 19, 2005 (gmt 0)

10+ Year Member



hmm..I used to use sendmail but mail() never worked (emails never got sent out)...could you please give me a step by step howto on how to setup sendmail? I don't want anything fancy, I just want to use it so people I host can use it to send emails from their scripts and forums like Invision Power Board.

Thanks in advance!

(yes, I've tried doing it by myself and reading material...but please I'd really appreciate it if you'd tell me how to go about this step by step - thanks!)

hexstar

4:14 am on Mar 19, 2005 (gmt 0)

10+ Year Member



oh and as a follow up...I could send mail through sendmail by using special php smtp functions but it was a pain and not everyone recieved the emails, basically the only people who did recieve them were gmail users....the rest of the email providers seemed to bounce back the emails because the server IP of 127.0.0.1 could not be resolved...please include in the step by step how to change this IP to my servers real, resolveable IP...thanks a ton!

jatar_k

4:43 am on Mar 19, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well, I have no idea how to set up sendmail but I will ask a sysadmin if they can give me a solid link to a tutorial.

emails not getting through is another issue all together. You need reverse lookup to resolve among many other things. That is not the same issue by far.

i will see if I can get someone to post about the whole shootin match but it may take a couple of days and you may be more then overwhelmed at the answer to what seemed like a fairly straight forward question.

hexstar

4:57 am on Mar 19, 2005 (gmt 0)

10+ Year Member



*sigh* I see that I'd need my ISP to delegate a static IP to my nameserver...I have a dynamic IP so this won't work :-(...is there anyway at all that I can get php mail() to just send the mail through my ISPs smtp server? if I comment out the sendmail option and use the smtp options even though they're marked for windows only will this work?

jatar_k

4:59 am on Mar 19, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



nah, they really only work properly in windows, though there may be other options, i will ask that as well.

hexstar

5:18 am on Mar 19, 2005 (gmt 0)

10+ Year Member



ok please let me know what the guy says, thanks :-)

coopster

2:14 pm on Mar 19, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The sendmail.org site doesn't offer much in terms of configuration [sendmail.org], unless I missed something. The redhat docs seem a bit better:

[redhat.com...]

MattyMoose

9:54 pm on Mar 21, 2005 (gmt 0)

10+ Year Member



There's a few things that you need to take care of.

I'm going to address them in a bottom->up sort of fashion, bottom being the basic necessities of your domain and DNS workings.

> *sigh* I see that I'd need my ISP to delegate a static IP to my nameserver...

Don't host your own nameserver. As you just mentioned, it's a terribly painful and expensive proposition if you're hosting things out of your house. either a) your IP changes and you need to notify your registrar, and it's now a propagation issue or b) you pay tonnes of money for a static IP. It used to be that I could get a second static IP for only $5 a month, now it's usually a requirement that you pay for a business-grade connection to get a pseudo-static IP.

The answer to that? Use a DNS hosting service. Something like Zoneedit or whatnot. I haven't tried any others, but ZE is free and easy to use, and you can use a dynamic updating tool (as simple as a script using lynx) to update your IP.

> hmm..I used to use sendmail but mail() never worked (emails never got sent out)...

Usually the reason for that is one of:
a) Your ISP blocks outbound port 25 connections to ANY outside system except their own (this is the case for me). This means that your ISP won't let your mail server (sendmail) deliver mail directly to the receiving domain's mailserver (the default behaviour).
b) Your mailserver is hosted on a home connection, or unfortunately in a bad subnet that's associated with home IP addresses. Most domains use Blacklists thatban incoming connections from IP addresses that are from ISP's dialup ranges or highspeed ranges. So basically your IP would resolve to a residential connection, and the receving server will say "Hell no! You're a zombie1 I'm not accepting any spam from you!".

> basically the only people who did recieve them were gmail users....the rest of the email providers seemed to bounce back the emails because the server IP of 127.0.0.1 could not be resolved.

That's partly because of the reason above, as well as 127.0.0.1 is not a real address that should be talking to anyone. So you didn't tell sendmail what its hostname was or its IP address, OR you gave your server's hostname the address 127.0.0.1 (ie, in /etc/hosts, you've got:

127.0.0.1       myservername

You didn't do that, right? Right?

What you need to do to route mail properly and legitimately is to treat your server as though it was a normal desktop. Think about the settings that are necessary for a desktop machine to email out through your ISP. More than likely what you'll need to do is relay through your ISP's mail servers. This is easily accomplished by editing your

/etc/mail/sendmail.cf
file.

Search for a key that says


# "Smart" relay host (may be null)
DS

The line that says just "DS", change it to:
[code]
DSmail.myisp.com
[/code[

(alter mail.myisp.com to the outobund mailserver for your domain).

Restart sendmail, and you should now be able to send mail to any domain.

Anyway, the short answer to a very long and complicated scenario is:

a) Get an external DNS hosting server (There are tonnes of free ones) and use their Dynamic updating service.
b) Set up the DS key in your sendmail config.

Hope that helps. :)
MM

coopster

12:48 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It's nice to see a knowledgable sys admin pop in and throw down when we really need it -- thanks for the insight, MattyMoose. As always, deeply appreciated :)

hexstar

3:36 pm on Mar 22, 2005 (gmt 0)

10+ Year Member



thanks for your help guys :-). Sendmail was really just unfriendly for me config-wise. So I'm using postfix instead now which works great, the config file is heavily commented and you don't need to rebuild the config file for it to take effect...and yep it was the ISP blocking port 25...luckily they had a form to remove the filter and now I can send email...and even cooler most if not all email providers are accepting my email from my server :-D (fixed 127.0.0.1 issue so mail server resolves to public IP), thanks for the help guys