It took me a while to figure this out. It might be a non-optimal solution, but seems to work.

If you have a GoDaddy (virtual) dedicated server, and want to send out emails, there are several gotchas.

First, you need to create an email user in Plesk. This sets up a user name and password pair. If you already have the server set up as a catch-all, you don’t need to create a directory for the user in Plesk or allow it to access webmail.

You can now use the SMTP server mail.example.com (where example.com is your domain name) to send outgoing emails, BUT you must send your user name and password. This is a good thing; otherwise the spammers will use it as an open relay for sending as many messages as they can pump through.

If you’re using PHP, there is a problem though. The mail() command is all set up and ready to go (!) but doesn’t support authentication. Therefore, every email you try to send from PHP will just fail silently. The trick is to switch to PEAR Mail.php instead.

The PEAR files are already installed on GoDaddy servers (twice!), but you won’t be able to run them from your domain. Some files are installed under /usr/share/pear/ and some more are under /home/httpd/vhosts/webmail/horde/pear/.

The files under /usr/share/pear/ don’t include all of the files (in particular Socket.php). The correct solution is probably to install an updated version of PEAR to this area. The way I did it was to piggy-back the webmail files that were already installed, as follows:

  1. Create a file conf/vhost.conf under the specific domain, containing the following:
<Directory /home/httpd/vhosts/example.com/httpdocs>
   <IfModule sapi_apache2.c>
      php_admin_value include_path "/home/httpd/vhosts/webmail/horde/pear/"
      php_admin_value open_basedir "/home/httpd/vhosts/example.com/httpdocs:
/tmp:/home/httpd/vhosts/webmail/horde/pear/"
   </IfModule>
</Directory>
  1. Run the following command:

/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=example.com

(this regenerates httpd.include under example.com to include the new vhost.conf)

  1. Restart apache:

apachectl graceful

Now you should be able to send email from PHP using a script along the following lines (copied from a comment in the PHP manual):

<?
    include("Mail.php");
    $recipients = "mail_to@domain.mail";
    $headers["From"]    = "mail_from@domain.mail";
    $headers["To"]      = "mail_to@domain.mail";
    $headers["Subject"] = "Test message";
    $body = "TEST MESSAGE!!!";
    $params["host"] = "smtp.server";
    $params["port"] = "25";
    $params["auth"] = true;
    $params["username"] = "user";
    $params["password"] = "password";
    // Create the mail object using the Mail::factory method
    $mail_object =& Mail::factory("smtp", $params);
    $mail_object->send($recipients, $headers, $body);
?>