duanfu2562 2013-09-05 06:28
浏览 901
已采纳

SMTP发送邮件时出错

I have been trying to send mail using wamp server in my laptop. The SMTP server is presented in online. Here is my php code to send mail:

<?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.";
?>

I also set my php.ini file like this:

[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

This is the error I am getting:

Warning: mail() [function.mail]: SMTP server response: 550-Please turn on SMTP Authentication in your mail client, or login to the 550-IMAP/POP3 server before sending your message. (vignesh-PC) 550-[115.118.170.201]:23328 is not permitted to relay through this server 550 without authentication. in C:\wamp\www\mailtofunc.php on line 12

What do I do now? Please help me guys...

  • 写回答

2条回答 默认 最新

  • dongqiang8474 2013-09-05 06:46
    关注

    I think its a problem with authentication. You need to add the SMTP user's username and password to the mail function to send the email.

      //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();
    

    You might be better off trying the PHP's Pear mail function, if you know how to use it.

    //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);
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题