Using mail()

Hi
I’m using the mail() function in my script to send an email for account activation. The issue I have is that the email is not arriving on my test email account. I get no errors so I assume that the script is correct.

I understand that I need to set the SMTP directive in PHP.ini but my host won’t let me change it for reasons I understand. Can I include my own PHP.ini in my root that will overide my hosts file or is there another alternative.

My host only references their smtp server as an ip address yet email from my php script still doesn’t get through.

Thanks
M

You can set a million php.ini files, but the server’s PHP engine will still only look at the one your host set up. So that’s not gonna work. If your host has disabled the mail() function, I’m pretty sure they did so for good reasons (mailing lists, spambots, etc. All bandwidth-eating scripts that hosting providers generally don’t like). Please contact your hosting provider to see if there are any alternatives, I’m pretty sure they can inform you better than we can :slight_smile:

My host won’t set the smtp address in the php.ini file.
How would I get around this so I can send mail from a php script?

Thanks
M

Get a virtual server from a hosting provider and install PHP4/5 yourself with the appropriate mail settings? As far as I know, settings from the hosting provider cannot be overruled in PHP (and no, we won’t help you hack your hosting server).

Host has suggested the following:

ini_set(“sendmail_from”, "[email protected]");

Not sure this will work. Is it an alternative?

thanks

If your host suggests it, it might just work. Be sure to know that this won’t set it permanently to your email address though (as ini_set() works with a script-wide scope only). For more information, visit PHP ini_set.

I say it’s worth a try :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service