2013-01-12 73 views
20

के साथ भेजते समय मेरे पास स्थानीयहोस्ट पर चल रहा एक ही PHP स्क्रिप्ट है - मेरा पीसी XAMPP और होस्टेड सर्वर पर चल रहा है। यह मेरे पीसी से काम करता है, लेकिन होस्टेड सर्वर से नहीं।"पासवर्ड से सर्वर स्वीकार नहीं किया गया: 535 गलत प्रमाणीकरण डेटा" जीमेल और phpMailer

जब मैं इसका आयोजन सर्वर से भेजने के लिए, मैं निम्नलिखित उत्पादन प्राप्त करें:

SMTP -> ERROR: Password not accepted from server: 535 Incorrect authentication data 
SMTP -> ERROR: RCPT not accepted from server: 550-Please turn on SMTP Authentication in your mail client, or login to the 550-IMAP/POP3 server before sending your message. dev.camppage.com 550-(patchvalues.com) [205.234.141.238]:50958 is not permitted to relay through 550 this server without authentication. 
SMTP Error: The following recipients failed: [email protected] FAILED 

मुझे लगता है कि वहाँ एक कॉन्फ़िगरेशन सेटिंग है कि सर्वर पर बदलने की आवश्यकता है, लेकिन मैं नहीं जानता कि जो एक । किसी भी सलाह की काफी सराहना की जाएगी!

function send_gmail ($recipients, $subject, $message, $attachment_filenames = array()) 
{ 
    global $email_address, $email_password, $email_name; 
    require_once ($_SERVER['DOCUMENT_ROOT']. '/php/PHPMailer/class.phpmailer.php'); 

    $body = $message; 
    $body = str_replace("\\", '', $body); 
    $mail = new PHPMailer(); 
    $mail->CharSet = "UTF-8"; 
    $mail->IsSMTP(); 
    $mail->Host  = "smtp.gmail.com";  // sets GMAIL as the SMTP server 
    $mail->SMTPDebug = 1;      // enables SMTP debug information (for testing) 0 - none; 1 - errors & messages; 2 - messages only 
    $mail->SMTPAuth = true;     // enable SMTP authentication 
    $mail->SMTPSecure = "ssl";     // sets the prefix to the servier 
    $mail->Port  = 465;     // set the SMTP port 
    $mail->Username = $email_address; // GMAIL username 
    $mail->Password = $email_password; // GMAIL password 
    $mail->SetFrom($email_address); 
    $mail->FromName = $email_name; 
    $mail->AddReplyTo($email_address,$email_name); 
    $mail->Subject = $subject; 
    $mail->MsgHTML($body); 
    $mail->IsHTML(true); // send as HTML 

    if (isset ($recipients[0])) 
    { 
    foreach ($recipients AS $to) 
    { 
     $to_pieces = explode (",", $to, 2); 
     $to_email = trim ($to_pieces[0]); 
     if (isset ($to_pieces[1])) 
      $to_name = trim ($to_pieces[1]); 
     else 
      $to_name = " "; 
     $mail->AddAddress($to_email, $to_name); 
    } 
    $mail->IsHTML(true); // send as HTML 

    if ($mail->Send()){ 
     return TRUE; 
    } else { 
     return FALSE; 
    } 
} 
else 
{ 
    return FALSE; 
} 
} 

TIA

उत्तर

43

समाधान सर्वर सेटिंग्स से बाहर जाने वाले एसएमटीपी सक्षम करने के लिए किया गया था:

यहाँ कोड है।

सीपीनल के डब्ल्यूएचएम चलाने वाले सर्वरों पर, यह डब्ल्यूएचएम की "ट्वीक सेटिंग्स" अनुभाग के तहत स्थित है।

विकल्प सक्षम/अक्षम करने के लिए है - अक्षम चुनें।

चेतावनी: यह परिवर्तन करना आउटगोइंग एसएमटीपी कनेक्शन रीडायरेक्ट करेगा, खातों को सीधे कनेक्शन बनाने की अनुमति देगा जो आपके सर्वर को ब्लैकलिस्ट करने की आपकी बाधाओं को बढ़ा सकता है।

+8

आप जीवन बचतकर्ता हैं। मैं पैनल में> Tweak सेटिंग पर उपयोग कर रहा हूँ CentOS 6 'लॉग इन> सभी> " रूट, एग्जिम, और डाकिए (FKA एसएमटीपी Tweak) करने के लिए बाहर जाने वाले एसएमटीपी सीमित करें "' <== उसे निष्क्रिय। मैं इसे किसी भी एक है कि एक ही समस्या –

+1

Dude मिला के लिए और अधिक विस्तार का वर्णन है, आप एक जीवन रक्षक हैं, मैं सही हताशा का निशानेबाज दस्ते के सामने था जब तुम मुझे बचाने के लिए अपने नायक सूट के साथ कहीं से आया था। धन्यवाद – Temitayo

+0

यूप। मेरी त्वचा भी बचाई। धन्यवाद! –

2
इस

WHM/cPanel से संबंधित है, तो आप इस

/scripts/smtpmailgidonly off 

टाइप करके पिछले जवाब में के रूप में या खोल से एक ही बात कर सकते हैं आप

"SMTP Mail protection has been disabled. All users may make outbound smtp connections." 

अधिक पढ़ने मिलना चाहिए यहां https://forums.cpanel.net/threads/cant-enable-smtp-restrictions.360971/