簡體   English   中英

發送郵件時出現SMTP錯誤

[英]SMTP Error on sending mail

我一直在嘗試使用筆記本電腦中的wamp服務器發送郵件。 SMTP服務器在線顯示。 這是我發送郵件的php代碼:

<?php
        ini_set( 'SMTP', "mail.vickey1192.co.in" );
        ini_set( 'smtp_port', 26 );
        ini_set( 'sendmail_from', "admin@vickey1192.co.in" );

        $to = "balavickey1192@gmail.com";
        $subject = "Acknowledgement";
        $message = "Thank you for registering with us<br>";
        $from = "no-reply@vickey1192.co.in";
        $headers = "From:" . $from;

        mail($to,$subject,$message,$headers);
        echo "Mail Sent.";
?>

我也將php.ini文件設置如下:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = mail.vickey1192.co.in
; http://php.net/smtp-port
smtp_port = 26

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = admin@vickey1192.co.in

這是我得到的錯誤:

警告:mail()[function.mail]:SMTP服務器響應:550-在發送郵件之前,請在郵件客戶端中打開SMTP身份驗證,或登錄到550-IMAP / POP3服務器。 (vignesh-PC)550- [115.118.170.201]:23328未經允許不得通過此服務器550進行中繼。 在第12行的C:\\ wamp \\ www \\ mailtofunc.php中

現在我該怎么做? 請幫我...

我認為認證存在問題。 您需要將SMTP用戶的用戶名和密碼添加到郵件功能中以發送電子郵件。

  //Using built in mail method
  $mail = new PHPMailer();
  $mail->Host = 'smtp.example.com'
  $mail->SMTPAuth = true;     // turn on SMTP authentication
  $mail->Username = 'your_username@example.com';  // a valid email here
  $mail->Password = 'replace_with_your_password';
  $mail->From = 'from@example.com';
  $mail->AddReplyTo('from@example.com', 'Test');

  $mail->FromName = 'Test SMTP';
  $mail->AddAddress('test1@example.com', 'test2@example.com');

  $mail->Subject = 'Test SMTP';
  $mail->Body = 'Hello World'; 

  $mail->Send();

如果您知道如何使用PHP的Pear郵件功能,則可能會更好。

//Using PEAR's mail function
<?php
  include('Mail.php');

  /* mail setup recipients, subject etc */
  $recipients = "your_recipients@example.com";
  $headers["From"] = "user@example.com";
  $headers["To"] = "feedback@example.com";
  $headers["Subject"] = "Some Subject";
  $mailmsg = "Hello, This is a test.";

  /* SMTP server name, port, user/passwd */
  $smtpinfo["host"] = "smtp.example.com";
  $smtpinfo["port"] = "25";
  $smtpinfo["auth"] = true;
  $smtpinfo["username"] = "smtpusername";
  $smtpinfo["password"] = "smtpPassword";

  /* Create the mail object using the Mail::factory method */
  $mail_object =& Mail::factory("smtp", $smtpinfo);

  /* Ok send mail */
  $mail_object->send($recipients, $headers, $mailmsg);

?>

您的郵件服務器需要接受身份驗證(用戶名+密碼),然后才能接受您的電子郵件。 建議您要么通過SMTP連接(使用SMTP AUTH,希望使用TLS)提供它,要么建議您在SMTP之前先做一種稱為POP的技術,在該技術中,您首先登錄並“檢查”郵件,這將導致主機的臨時白名單因此它可以稍后發送郵件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM