$from = "someonelse@example.com";
$headers = "From:" . $from;
echo mail ("borutflis1@gmail.com" ,"testmailfunction" , "Oj",$headers);
我在用PHP发送电子邮件时遇到了问题。我得到一个错误:SMTP server response: 530 SMTP authentication is required
。
我的印象是,你可以发送没有SMTP验证的电子邮件。我知道这封邮件可能会被过滤掉,但现在这并不重要。
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = someonelse@example.com
这是php.ini
文件中的设置。如何设置SMTP?是否有不需要验证的SMTP服务器,或者必须自己设置服务器?
发布于 2013-01-22 18:46:57
当您通过需要SMTP身份验证的服务器发送电子邮件时,您确实需要指定它,并设置主机、用户名和密码(如果不是默认端口,还可以设置端口- 25)。
例如,我通常使用与以下设置类似的PHPMailer:
$mail = new PHPMailer();
// Settings
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "mail.example.com"; // SMTP server example
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "username"; // SMTP account username example
$mail->Password = "password"; // SMTP account password example
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
你可以在这里找到更多关于PHPMailer的信息:https://github.com/PHPMailer/PHPMailer
发布于 2013-01-22 19:21:48
<?php
ini_set("SMTP", "aspmx.l.google.com");
ini_set("sendmail_from", "YOURMAIL@gmail.com");
$message = "The mail message was sent with the following mail setting:\r\nSMTP = aspmx.l.google.com\r\nsmtp_port = 25\r\nsendmail_from = YourMail@address.com";
$headers = "From: YOURMAIL@gmail.com";
mail("Sending@provider.com", "Testing", $message, $headers);
echo "Check your email now....<BR/>";
?>
或者,有关更多详细信息,请参阅read on。
发布于 2013-12-03 05:52:08
https://stackoverflow.com/questions/14456673
复制相似问题