繁体   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