Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


PHP Mail Script will send to MY domain but NEVER outside

Posted on 2004-03-23
Medium Priority
Last Modified: 2007-12-19
Purchased a Clickbank script some time back and it installed great.  When an affiliate signs up or a customer purchases a product they will get some type of e-mail via this script.  Either telling the affiliate they made a sale, welcome to the program or giving the customer download instructions.

Recently, all e-mail from this script quit working EXCEPT if the address being sent to was @freedomfly.net (MY domain).

I contacted my host and they responded with:

The problem is that you're sending mail out from mrcd@stkitts.globat.com. The script
has to be written properly.  If you want to send mail out from globat's servers, you
have to use your globat account *@freedomfly.net.

I contacted the developer and he responded with:

The code for the mail function is a simple one, it uses the
standard php "mail()" function.  The email headers are
determined by how the server and php is setup.

I think you need to ask them this question -
can you use the php  mail() function  OR do you need
to use the SMTP function to send mail.

These are the only 2 ways to send email. If they say
SMTP function, then I'll need you to do the following.

1) create a new mailbox (not a forwarder) and give
   me the username/password for that mailbox

2) I'll modify eCM's code to use it. It should work, unless
it requires your master/main mailbox details.

I've got a php.ini file on my domain.  And when I connect to this page:


I can see all kinds of variables.  I think the php.ini file that is in my domain will allow me to control some.. like the mail account I send from.  Which is setup with a valid address, but does nothing to resolve my problem.

CGI scripts work just fine.  

My main question is:

Why doesn't the php.ini file make a difference?  How can I send mail using this script's simple php function?  Since the developer made the script so simple, I'm thinking he did not include this FROM function.

Can that simply be added?

If you need access to the scripts in question, I can provide a zipped file.

Question by:Defcon5
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2

Author Comment

ID: 10661913
PHP on my host is compiled as CGI.  I have no idea why, but it's the answer they gave me.
LVL 25

Accepted Solution

Marcus Bointon earned 1000 total points
ID: 10663504
Not a solution, but some suggestions. It's quite likely that your ISP blocks SMTP traffic on port 25, or redirects it to their server, which might be enough to fool your scripts, and possibly prevent you from using a PHP SMTP client. Alternatively, they might not allow modification of the from header to indicate a domain other than one of theirs.

It sounds like the mail function being used by the script may be a little too simple. It might be a good idea to ask them to use PHPMailer instead (phpmailer.sourceforge.net) as it has built-in SMTP support and lots of stuff that the standard mail function doesn't do. I don't have any trouble using it to set from addresses, but then I'm using my own server and don't have the constraints of virtual hosting.

Because sending is done with SMTP, there isn't really a concept of mailboxes, so the setting in the ini file can be arbitrary (and you can override it on the fly using ini_set).

Author Comment

ID: 10663924
Here's why..

As long as mrcd@stkitts.globat.com is included in our spamlist, your form will not work.

They are blocking the e-mail that it defaults to.. it either comes from a valid domain (@freedomfly.net) or it's crap.

Nice.. my own host in an effort to be 'pro-active' is blocking my own default generated message.

Even thought it comes from the e-mail address that is set in the control panel, I guess it's not really.

My CGI newsletter script allows a from field but it might declare it better.

I'm not able to convince them to complile in Apache.  And there is little hope they will use a PHPMailer.

Can I get the developer of the script to use SMTP somehow?

I can make a mailbox on my domain.. and maybe the script can use authenticated SMTP to send mail rather then simple PHP.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 10664486
No luck. I've uploaded 2 files - "smtpmail.php" and "pinfo.php"
Please edit those 2 files to play around with the settings.

1) smtpmail.php (this provides the function to send email via SMTP.  I've define the following in this file.

define("MAIL_SERVER","mail.freedomfly.net");      // Put Your mail
server name here
define("MY_SITE","freedomfly.net");            // Put Your site name here
define("MAIL_BOX","something");                   // Put the valid
mailbox from the above domain
define("MAIL_PSW","testpassword");        // Put the password for
the above mailbox

2)  File: "pinfo.php"
Then, browse this page - www.freedomfly.net/pinfo.php It *should* send you an email telling you which mail function work.

So when I go to that URL.. nada.. just get the basic config for my php on my domain.

I asked the host for a sample PHP mail script that works.. they directed me to hotscripts.com
LVL 25

Expert Comment

by:Marcus Bointon
ID: 10665348
PHPMailer is a PHP class that you can use in your scripts, it's not dependent on your ISP, and they don't have to install anything. If you can use PHP, you can use PHPMailer. It can do sendmail, qmail and direct SMTP sending, with and without authentication, and you can easily set from, reply-to and return-path headers on the fly. Obviously you will need changes in your sending script to use it. PHPMailer is most likely better than anything on hotscripts.

Have you tried doing a manual SMTP session? See what exactly their mail server is doing to your requests and why they're not going through. Try working through one of these guides (ignore the windowsisms) substituting your own parameters:


The pinfo.php page just dumps the usual output from phpinfo(), no mention of sending email.

Assisted Solution

robinet02 earned 1000 total points
ID: 10675242
your emails are probably blocked by the email system of your provider, probably sendmail, not a the PHP level.
your php.ini cannot do anything about that.

One simple solution could maybe be to add the 'From:' header to your sent emails.
To do that, just add ", "From: script@freedomfly.net" at the end of the mail() function.

Example :

mail("test@testaddress.com", "subject test", "test body", "From: script@freedomfly.net");

the 4th part of the php mail() function contains the additional headers ...
Try sending one to you by modifying the "test" address to see if it works.

Author Comment

ID: 10679563
Seems like I'm already declaring the FROM field in the php file that I'm using.

$host = getenv("HTTP_HOST");

// -----------------------------------
// Testing Simple php mail() function
// -----------------------------------
mail("adrian@easybiztools.com","Mail fr $host","test 456","From: mrcd@freedomfly.net");

// -----------------------------------
// Testing SMTP mail() function
// -----------------------------------

smtpmail("adrian@easybiztools.com","SMTP Mail fr $host","test 456","mrcd@freedomfly.net");


Expert Comment

ID: 10680925
and this test script doesn't work ? the simple "mail()" function ?
it should, even with your host strict regulations ...
Maybe you should ask them why it doesn't, as long as your are sending from your own domain ...

Author Comment

ID: 10681181

I opened a ticket.. asked my host to simply give me a sample PHP script that will send from my domain.

They replied with "we will have to escalate this to the admin"

Duh!  Because I'm starting to think that any PHP mail will not work because they configured it wrong.

Glad to know somebody else thinks the same as me.  Some great suggestions in this thread!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question