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:
- Told me PEAR Mail wouldn't work
- I tested this and it did, so the first tech was incorrect
- Via email, got a test script from them using PEAR
- Tested it and it worked, but no SMTP
- Then, they gave me other SMTP servers
- Tested these and they worked as well, but still without SMTP
- I asked why couldn't I just use other email servers, like smtp.gmail.com
- Then, they told me I had to change my MX record
- I then asked why since I didn't want to do this yet and that I wanted to just use another SMTP server
- They told me that this wasn't possible
- I began getting confused and came here for help
This was solved by adjusting the paths of PEAR on the server. I actually installed it in another directory and pointed my functions there.