Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm starting to not like 1and1.com that much. I've used them for years, but mainly for simple sites without much need for configuration. I know there are better hosting companies out and I may go seeking them.

The problem here is that on my Local XAMPP server (sitting on a network with Comcast ISP), I have a PHP script that uses PEAR::Mail to send mail using MIME. The script works find locally with either smtp.1and1.com and corresponding credentials and smtp.gmail.com with corresponding credentials, using appropriate ports, etc.

1and1 tells me that I have to change the MX record on the domain where this script runs in order to make this work. This doesn't make sense to me.

Versions:

PEAR Version: 1.5.0
PHP Version: 4.4.9
Zend Engine Version: 1.3.0

I understand that the systems (servers) are very much different (thanks to nojak for bringing this up; my original question was vague). The OSes, PHP versions, and probably many other configurations are quite different. My main question is if PEAR and PHP have the email functionality in both cases and my script works on my local setup, what kind of things will make the 1and1 servers not work? I'm looking for other troubleshooting to try.

My apologies in advance for my ignorance. Thanks for the help in advance.

EDIT

Here is my function:

require_once('Mail.php');
require('Mail/mime.php');

function send_form_mail($body) {

    $from = "<***>";
    $to = "<***>";
    $subject = $body[0];
    $host = "smtp.1and1.com";
    $port = "587";
    $username = "***";
    $password = "***";

    $headers = array(
        'From' => $from,
        'To' => $to,
        'Subject' => $subject
    );

    $smtp = Mail::factory('mail', array(
        'host' => $host,
        'port' => $port,
        'auth' => true,
        'username' => $username,
        'password' => $password
    ));

    $text_field_array = array(
        '',
        ''
    );

    for ($i = 1, $size = sizeof($body) + 1; $i < $size; $i++) {      
        $text_body .= $text_field_array[$i] . $body[$i] . '\n';
    }

    $html_field_array = array(
        '',
        ''
    );

    for ($i = 1, $size = sizeof($body) + 1; $i < $size; $i++) {          
        $html_body .= $html_field_array[$i] . $body[$i] . '<br />';
    }

    $mime = new Mail_mime();
    $mime -> setTXTBody($text_body);
    $mime -> setHTMLBody($html_body);

    $email_body = $mime -> get(); 
    $headers = $mime -> headers($headers);

    $mail = $smtp -> send($to, $headers, $email_body);

    if (PEAR::isError($mail)) {
        echo("<p>We've encountered and an error: " . $mail -> getMessage() . "</p>");
    }
}

Please note that I starred out sensitive characters in function above.

Here are the main points 1and1 shared with me:

  1. Told me PEAR Mail wouldn't work
  2. I tested this and it did, so the first tech was incorrect
  3. Via email, got a test script from them using PEAR
  4. Tested it and it worked, but no SMTP
  5. Then, they gave me other SMTP servers
  6. Tested these and they worked as well, but still without SMTP
  7. I asked why couldn't I just use other email servers, like smtp.gmail.com
  8. Then, they told me I had to change my MX record
  9. I then asked why since I didn't want to do this yet and that I wanted to just use another SMTP server
  10. They told me that this wasn't possible
  11. I began getting confused and came here for help
share|improve this question
    
For one, you're not running the same virtualized environment at home, and probably not even the same Unix/Linux kernel nor distro. Don't just automatically assume that because it works on you "home" development environment, that it will work on any and every other server setup just because you're using the same types packages. If your device environment was ABSOLUTELY IDENTICAL in every way, including using the same backend setup and virtualization software, then you probably be safe to assume it would work. But not in any other case . –  nojak Aug 30 '12 at 23:06
    
That makes sense, and I understand this concept. I was not assuming the environments were identical; rather, I would like to try to figure out why this particular process isn't working. I have identified several inconsistencies already, like PHP version, for example. I will edit to be more clear. –  nicorellius Aug 30 '12 at 23:35
    
What exactly did 1and1 tell you, and how exactly did you configure PHP and the server that's "not working"? –  Michael Hampton Aug 30 '12 at 23:39
    
They told me several things, all of which I tried, one by one... First, I called them and the tech told me PEAR Mail wouldn't work with my script. I then SSH-ed into the server and saw that the PEAR packages are indeed installed, but are older versions. Next, via email, they referred me to a script that used PEAR and I tried it and it worked, but it didn't use SMTP authentication. And the list goes on. I think I should edit the post again with major points instead of listing everything in this comment. Thanks for the guidance. –  nicorellius Aug 30 '12 at 23:45
    
Can you elaborate on what you mean when you say "tested and it worked, but no smtp"? If the script doesn't work with smtp, then it doesn't work. Or do you mean it will communicate with the smtp servers, but not pass credentials to it or fail to verify credentials? Also, when you say they gave you other smtp servers, do you mean they installed other MTAs, or something told you different smtp servers to try connecting to? –  nojak Aug 31 '12 at 2:18
add comment

1 Answer

up vote 0 down vote accepted

This was solved by adjusting the paths of PEAR on the server. I actually installed it in another directory and pointed my functions there.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.