#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    260
    Rep Power
    0

    Cannot Send An Email


    I am using phpmailer to provide sending email feature in my application. It uses Gmail SMTP. The problem is, an email cannot be sent from my application. However, I created another folder name emailtest in the similar root folder and place email testing code in this folder, and it works. How can it be like this? The error I got is:

    SMTP -> ERROR: Failed to connect to server: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)
    SMTP Error: Could not connect to SMTP host.

    PHP Code:
    <?php
    include("phpmailer/class.phpmailer.php");
    include(
    "phpmailer/email_config.php");

    function 
    committeeEmails()
    {
        
    $arrEmail = array(    'eizan.aziz@gmail.com' => 'Eizan Aziz'
                            
    'eizan@pahang.uitm.edu.my' => 'Eizan Aziz');
        return 
    $arrEmail;
    }            = new 
    PHPMailer();
    $mail->IsSMTP();                
    $mail->SMTPDebug  SMTP_DEBUG;  
    $mail->SMTPAuth   SMTP_AUTH;  
    $mail->SMTPSecure SMTP_SECURE
    $mail->Host       HOST;        
    $mail->Port       PORT;       
    $mail->Username   USERNAME;   
    $mail->Password   PASSWORD;  

    $mail->SetFrom('itec2013@pahang.uitm.edu.my''Email Test');
    $mail->Subject 'New Team Registration';
    $body "This email is sent from emailtest folder.";
    $mail->MsgHTML($body);
    foreach(
    committeeEmails() as $email => $name)
    {
        
    $mail->AddAddress($email$name);    
    }
    $mail->Send();
    $mail->SmtpClose();
    if (
    $mail->IsError()) 

        echo 
    "ERROR<br /><br />";
    }
    else 
    {
        echo 
    "OK<br /><br />";
    }
    ?>
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Read the error message. It couldn't connect to the email server. That means these lines are wrong:
    PHP Code:
    $mail->Host       HOST;         
    $mail->Port       PORT
    Go find where you define HOST and PORT and make them the proper values.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Blackburn, Lancashire.
    Posts
    8
    Rep Power
    0
    Hi,

    Is your SMTP server using the standard port (usually 25) or something different? Maybe your host has some information regarding this.

    Regards,

    petemaxi.

IMN logo majestic logo threadwatch logo seochat tools logo