Skip to main content
Help Center
The GoDaddy Community will undergo maintenance starting on Wednesday, July 28th at 3pm PST / 6pm EST. Learn more
  • GoDaddy Community
  • Building & Managing Client Sites
  • Building & Managing Client Sites

    Showing results for 
    Show  only  | Search instead for 
    Did you mean: 

    Mailer Error: SMTP Error: Could not connect to SMTP host.

    I am working on a customer site to add an email contact page.  When I go to send the email I get the error:


    Mailer Error: SMTP Error: Could not connect to SMTP host.


    I am using the PHP FormHandler library found here:


    My understanding is that with the cPanel, you simply use the sendmail server on the localhost and do NOT need a username/password.  This is the code to send the email, what do I have wrong?


    At the moment I have the emails going to my gmail account for testing.  Once I get that working I will send it to the customer's Exchange server which has a Barracuda spam filter in front of it.


    define('__ROOT__', dirname(dirname(__FILE__)));
    require_once(__ROOT__ . '/vendor/autoload.php');
    use JustCoded\FormHandler\FormHandler;
    use JustCoded\FormHandler\Handlers\MailHandler;
    use JustCoded\FormHandler\DataObjects\MailMessage;
    use JustCoded\FormHandler\FileManager\FileManager;
    $validationRules  = [
        'fields' => [
    			'fname' => ['required'],
    			'lname' => ['required'],
    			'email' => ['required', 'email'],
    			'message' => [ 'required', ['lengthMin', 5] ]
    			], // according to Valitron doc for mapFieldsRules.
            'labels' => [
            'name' => 'Name',
            'email' => 'Email address',
            'message' => 'Message',
    	] // according to Valitron doc.
    // Mandrill config.
    $mailerConfig = [
        'mailer' => MailHandler::USE_PHPMAILER,
        'host' => 'localhost',             // set your smtp host.
        'user' => '',                      // set email.
        'password' => '',                  // set password.
        'protocol' => 'FALSE',             // 'tls', 'ssl' or FALSE for not secure protocol/
        'port' => 25,                      // your port. (was 587 for tls)
        'attachmentsSizeLimit' => 8000000, // around 8MB.
    $message = [
        'from' => ['' => 'webSite'],
        'to' => ['<my_account>' => 'me me me'],
        'subject' => 'Contact request from {fname} {lname}',
        'bodyTemplate' => __DIR__ . '/template-html.php',
        'altBodyTemplate' => __DIR__ . '/template-plain.php'
    $mailer = new MailHandler($mailerConfig, new MailMessage($message));
    $formHandler = new FormHandler($validationRules, $mailer);
    if ($formHandler->validate($_POST)) {
    echo $formHandler->response();
    // write errors and return back.
    setcookie('advanced_response', $formHandler->response());
    header('Location: index.php');


    0 REPLIES 0