php 语言字符串加载失败:from_failed[from_email_address]

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9109261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:11:30  来源:igfitidea点击:

Language string failed to load: from_failed[from_email_address]

phpphpmailer

提问by N?m Lùn

I got this error when trying to send an email using smtp:

尝试使用 smtp 发送电子邮件时出现此错误:

Language string failed to load: from_failed**[email protected]**

Here's my code:

这是我的代码:

$mail = new PHPMailer();
                    //$mail->SetLanguage('en',dirname(__FILE__) . '/phpmailer/language/');
                    $SMTP_Host = "smtp.gmail.com";
                    $SMTP_Port = 465;
                    $mail->SMTPSecure = 'ssl';

                    $SMTP_UserName = "[email protected]";
                    $SMTP_Password = "****";
                    $from = "[email protected]";
                    $fromName = "My Name";
                    $to = "[email protected]";

                    $mail->IsSMTP();
                    $mail->Host     = $SMTP_Host;
                    $mail->SMTPAuth = true;


                    $mail->Username = $SMTP_UserName;
                    $mail->Password = $SMTP_Password;

                    $mail->From     = "[email protected]";
                    $mail->FromName = "From Name";
                    $mail->AddAddress("[email protected]");
                    $mail->AddReplyTo($from, $fromName);

                    $mail->IsHTML(true);

                    $mail->Subject  =  "This is an message from our website";
                    $mail->Body     =  $design;

                    if(!$mail->Send())
                    {

                       echo "Error : " . $mail->ErrorInfo;
                       exit;
                    }

How can I fix it?

我该如何解决?

回答by Mob

This usually means your phpMailer class cannot find the language file when it is trying to spit out a message.

这通常意味着您的 phpMailer 类在尝试吐出消息时找不到语言文件。

Easiest way to fix this is to set the language manually including the path to the language folder:

解决此问题的最简单方法是手动设置语言,包括语言文件夹的路径:

$mail = new PHPMailer();
$mail->SetLanguage("en", 'includes/phpMailer/language/');

It's in your language folder. Or you can simply point your SetLanguagemethod to this source:

它在您的语言文件夹中。或者您可以简单地将您的SetLanguage方法指向此来源:

  1  <?php
   2  /**
   3   * PHPMailer language file.  
   4   * English Version
   5   */
   6  
   7  $PHPMAILER_LANG = array();
   8  
   9  $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
  10                                       'recipient email address.';
  11  $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
  12  $PHPMAILER_LANG["execute"] = 'Could not execute: ';
  13  $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
  14  $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
  15  $PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
  16  $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
  17                                         'recipients failed: ';
  18  $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
  19  $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
  20  $PHPMAILER_LANG["file_access"] = 'Could not access file: ';
  21  $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
  22  $PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
  23  ?>

回答by vivek dhamecha

You can use systems internal mail function. In this case, phpMailer could not connecting correctly with SMTP. Better to use the servers 'mail' function to send the mail with phpMailer.

您可以使用系统内部邮件功能。在这种情况下,phpMailer 无法与 SMTP 正确连接。最好使用服务器的“邮件”功能通过 phpMailer 发送邮件。

replace

代替

$mail->IsSMTP();

to

$mail->Mailer = "mail";

I hope now your scripts works fine because we are using systems internal 'mail' function with phpMailers features.

我希望现在您的脚本可以正常工作,因为我们正在使用具有 phpMailers 功能的系统内部“邮件”功能。

回答by Sanjeev Chauhan

If you are using SMTP check your SMTP username and password. I had the same problem gmail password was updated by client.

如果您使用 SMTP,请检查您的 SMTP 用户名和密码。我遇到了同样的问题,客户端更新了 gmail 密码。