2013-03-07 9 views
17

मैं स्थानीय रूप से होस्ट किए गए PHP कोड के माध्यम से ईमेल भेजना चाहता हूं।PHP: स्थानीयहोस्ट में मेल भेजें

Warning: mail() [<a href='function.mail'>function.mail</a>]: Failed to connect to mailserver at &quot;localhost&quot; port 25, verify your &quot;SMTP&quot; and &quot;smtp_port&quot; setting in php.ini or use ini_set() in C:\... 

मैं php.ini फ़ाइल में चला गया और यह पहले से ही अच्छी तरह से विन्यस्त किया जा रहा है:

<?php 
$email = "[email protected]"; 
$titre = "My subject"; 
$message = "Text message !"; 
mail($email, $titre, $message); 
?> 

मुझे इस कोड चलाने के लिए, मैं निम्नलिखित त्रुटि मिलती है।

[mail function] 
; For Win32 only. 
; http://php.net/smtp 
SMTP = localhost 
; http://php.net/smtp-port 
smtp_port = 25 

मैं इसे कैसे ठीक कर सकता हूं?

धन्यवाद

+0

आप नहीं स्थानीय होस्ट जैसे 'पर, स्थानीय होस्ट से मेल भेज सकते कुछ अन्य smtp कॉन्फ़िगर करें:, गूगल याहू ...' –

+0

"MailServer से कनेक्ट करने में विफल रहा है" ... आप PHP के लिए कॉन्फ़िगर किए से कनेक्ट करने के स्थानीयहोस्ट पर एक मेलसर, पोर्ट 25. क्या आपने ऐसे मेलसर्वर को स्थापित किया है? – eis

+0

आपकी चल रही प्रणाली क्या है? –

उत्तर

12

यह मेल सर्वर के लिए localhost:25 उपयोग करने के लिए कॉन्फ़िगर किया गया है।

त्रुटि संदेश कहता है कि यह localhost:25 से कनेक्ट नहीं हो सकता है। ठीक तरह से कुछ अन्य एसएमटीपी सर्वर को इंगित करते हैं कि आप से कनेक्ट कर सकते स्थानीय होस्ट पोर्ट 25

  • बदलें विन्यास पर एक एसएमटीपी सर्वर कॉन्फ़िगर

    1. स्थापित करें /:

      इसलिए आपके पास दो विकल्प

  • +13

    बहुत उपयोगी उत्तर नहीं है। आपने मूल रूप से कहा है कि यदि यह काम नहीं कर रहा है तो इसे काम करें या कोई अन्य सर्वर बनाएं। – mgrenier

    +0

    @mgrenier - दूसरे उत्तर के विरोध में? एक उत्पाद की सिफारिश विषय बंद हो जाएगा। – Quentin

    +2

    @mgrenier की टिप्पणी के विपरीत, मैंने पाया कि यह शायद सबसे बुनियादी, अभी तक जानकारीपूर्ण प्रतिक्रिया ऑनलाइन लॉल है। "इसके टूट गया" .... "इसे ठीक करें" मेरे लिए काफी आसान है। – jjonesdesign

    0

    कोशिश इस

    ini_set("SMTP","aspmx.l.google.com"); 
    $headers = "MIME-Version: 1.0" . "\r\n"; 
    $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; 
    $headers .= "From: [email protected]" . "\r\n"; 
    mail("[email protected]","test subject","test body",$headers); 
    
    +0

    यह काम नहीं किया। – ravisoni

    5

    ऐसा करने के लिए आपको स्थानीय मेलसर्वर स्थापित करने की आवश्यकता होगी। यदि आप इसे बाहरी ई-मेल पते पर भेजना चाहते हैं, तो यह अवांछित ई-मेल में समाप्त हो सकता है या यह बिल्कुल नहीं पहुंच सकता है।

    एक अच्छा mailserver जो मैं का उपयोग करें (मैं लिनक्स पर इसका इस्तेमाल करते हैं, लेकिन यह विंडोज के लिए भी उपलब्ध है) Axigen है: http://www.axigen.com/mail-server/download/

    आप mailservers इसे स्थापित करने के साथ कुछ अनुभव की आवश्यकता हो सकती है, लेकिन एक बार यह काम करता है, तो आप आप जो कुछ भी चाहते हैं वह कर सकते हैं।

    5

    मैंने इस पर घंटों बिताए। मुझे त्रुटियां नहीं मिलीं लेकिन मेल कभी नहीं भेजे गए थे। अंत में मुझे एक समाधान मिला और मैं इसे साझा करना चाहता हूं।

    <?php 
    include 'nav.php'; 
    /* 
        Download PhpMailer from the following link: 
        https://github.com/Synchro/PHPMailer (CLick on Download zip on the right side) 
        Extract the PHPMailer-master folder into your xampp->htdocs folder 
        Make changes in the following code and its done :-) 
    
        You will receive the mail with the name Root User. 
        To change the name, go to class.phpmailer.php file in your PHPMailer-master folder, 
        And change the name here: 
        public $FromName = 'Root User'; 
    */ 
    require("PHPMailer-master/PHPMailerAutoload.php"); //or select the proper destination for this file if your page is in some //other folder 
    ini_set("SMTP","ssl://smtp.gmail.com"); 
    ini_set("smtp_port","465"); //No further need to edit your configuration files. 
    $mail = new PHPMailer(); 
    $mail->SMTPAuth = true; 
    $mail->Host = "smtp.gmail.com"; // SMTP server 
    $mail->SMTPSecure = "ssl"; 
    $mail->Username = "[email protected]"; //account with which you want to send mail. Or use this account. i dont care :-P 
    $mail->Password = "trials.php.php"; //this account's password. 
    $mail->Port = "465"; 
    $mail->isSMTP(); // telling the class to use SMTP 
    $rec1="[email protected]"; //receiver. email addresses to which u want to send the mail. 
    $mail->AddAddress($rec1); 
    $mail->Subject = "Eventbook"; 
    $mail->Body  = "Hello hi, testing"; 
    $mail->WordWrap = 200; 
    if(!$mail->Send()) { 
    echo 'Message was not sent!.'; 
    echo 'Mailer error: ' . $mail->ErrorInfo; 
    } else { 
    echo //Fill in the document.location thing 
    '<script type="text/javascript"> 
             if(confirm("Your mail has been sent")) 
             document.location = "/"; 
         </script>'; 
    } 
    ?> 
    
    संबंधित मुद्दे