我一直在尝试使用笔记本电脑中的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 发送邮件前的服务器。 (维涅什-PC) 550- [115.118.170.201]:23328不允许通过此传递 服务器550没有认证。在C:\ wamp \ www \ mailtofunc.php上 第12行
我现在该怎么办?请帮帮我们......
答案 0 :(得分:3)
我认为这是身份验证的问题。您需要将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);
?>
答案 1 :(得分:2)
您的邮件服务器需要身份验证(用户名+密码)才能接受您的电子邮件。它建议您通过SMTP连接(使用SMTP AUTH,希望使用TLS)提供,或者您使用名为POP before SMTP的技术,首先登录并“检查”您的邮件,这将导致临时白名单你的主人所以它可以在短时间内发送邮件。