簡體   English   中英

PHP mail()不發送電子郵件

[英]PHP mail() doesn't send e-mail

我有一個問題要問大家。

我注意到我的php郵件不再發送了。 因此,我調查了一下以確定問題所在,但似乎找不到。

就是這種情況:

在Powershell 3(Server 2012)中,我使用以下命令:

send-MailMessage -SmtpServer smtp.versatel.nl

在給收件人電子郵件地址,主題和發件人地址之后,它可以毫無問題地發送郵件。

PHP文件中的代碼是:

INI_SET("SMTP", "smtp.versatel.nl");
$success = mail($to, $subject, $body, $header);

preg_match("/\d+/", $error["message"], $error);
if(!$success){$this->sFoutmelding ='Email is niet verstuurd.'.print_r($error);}

在php.ini中,我禁用了默認的ini設置:

mail function]
; For Win32 only.
; SMTP = Smtp.versatel.nl
; smtp_port = 25

但是仍然收到未發送郵件的錯誤消息:

Array ( )
Email is niet verstuurd.1

為什么Powershell完美地做到了,PHP為什么不發送郵件? 任何想法都可以接受,我整周都在互聯網上搜索過,但我找不到答案。

*編輯

我嘗試了var_dump,並且按預期提供的只是“ FALSE”。

同樣,'localhost'中的更改也無法解決問題。 仍在搜索中...

它的工作原理,但仍然沒有理由為什么:-)所以,如果有人知道為什么,我也想知道它:-)

它仍然使用與沒有phpmailer類相同的smtp服務器。 因此,我唯一能想到的是,與默認的PHP相比,PHPmailer創建了一個不同的,更加奇怪的郵件標頭。

我添加了以下代碼和類PHP郵件程序:

$success = $this->mail_attachment($to, $subject, $body);

protected function mail_attachment($mailto, $subject, $message) {
require_once("../PHPMailer/class.phpmailer.php");
//$file = $path.$filename;
$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP
$mail->Host     = "smtp.versatel.nl"; // SMTP server

$mail->From     = "noreply@provider.foo";
$mail->FromName = "Sendername";
$mail->AddAddress($mailto);


$mail->Subject  = $subject;
$mail->Body     = $message;
$mail->WordWrap = 75;
//$mail->AddAttachment($file);

    if(!$mail->Send()) {
      echo 'Bevestigings e-mail is niet verzonden.';
      echo 'Mailer error is: ' . $mail->ErrorInfo;
    }
}

暫無
暫無

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

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