Using php on WinHost - need help!

Discussion in 'Site Programming, Development and Design' started by fairsalvage, Feb 23, 2012.

  1. Need to use a form to collect information from visitors to my Web site. Using Expression Web 4 and php. Kept getting erros to contacted Winhost support and received this message:
    It looks like you are trying to use localhost as the smtp server. Localhost signifies the web servers smtp service. The web server does not have smtp service enabled. You will need to use the actual mail server assigned to your email account and you will need to pass smtp authentication.

    Read this kb article as an example code on how you may code your PHP application to send email through your email account.

    http://support.Winhost.com/KB/a826/how-to-send-email-from-a-php-application.aspx

    Ok . . . so fixed the setting in my server to allow smtp traffic from Winhosts IP through the firewall and added a relay to the exchange server. But can't figure out the proper code from the above provided link to ad to my php page to make it work!
     
    Last edited by a moderator: Oct 14, 2015
  2. Elshadriel

    Elshadriel Winhost Staff

    You need to post some code and perhaps a URL so we can review the error.
     
  3. Code

    Ok, here you go . . . been working with a programmer but still doesn't work. Here's the code for the send.php page:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Send Form Info</title>
    </head>

    <body>

    <?php
    $msg =$_POST['information'];
    $to='[email protected]';
    $subject='Web Site Email Registration';

    mail($to,$subject,$msg);
    echo 'Thanks for the submission.';
    ?>

    <?
    require_once "Mail.php";
    $from = "Sender <[email protected]>";
    $to = "Recipient <[email protected]>";
    $subject = "This is a test email sent via php";
    $body = "This is a test email";
    $host = "mail.fairsalvage.com";
    $username = "todd";
    $password = "temporary";
    $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);
    $smtp = Mail::factory('smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));
    $mail = $smtp->send($to, $headers, $body);


    // Additional headers
    $headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
    $headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
    $headers .= 'Cc: [email protected]' . "\r\n";
    $headers .= 'Bcc: [email protected]' . "\r\n";

    ?>


    </body>

    </html>

    We are using MailMax email server and according to our IT gal that was the problem. She has since "fixed" it so just for the sake of this form we are using our server instead. All the code for "additional headers" was added by her to "experiment" but still get the error. Thanks a lot!
     
  4. It's going to be difficult for us to troubleshoot since your mx records don't point to us:

    # dig mx fairsalvage.com

    ;; QUESTION SECTION:
    ;fairsalvage.com. IN MX

    ;; ANSWER SECTION:
    fairsalvage.com. 3600 IN MX 10 mail1.mxsmtp.com.
    fairsalvage.com. 3600 IN MX 20 mail2.mxsmtp.com.
    fairsalvage.com. 3600 IN MX 30 mail3.mxsmtp.com.
    fairsalvage.com. 3600 IN MX 40 mail4.mxsmtp.com.
    fairsalvage.com. 3600 IN MX 99 m05.internetmailserver.net.

    By the way, you can't use m05.internetmailserver.net the way you've got it set up there, as a backup. You might as well remove it from your DNS record.

    You also haven't mentioned what the errors are/were with your script...
     

Share This Page