【问题标题】:Language string failed to load: from_failed[from_email_address]语言字符串加载失败:from_failed[from_email_address]
【发布时间】:2012-02-02 08:35:38
【问题描述】:

我在尝试使用 smtp 发送电子邮件时收到此错误:

Language string failed to load: from_failed**myemail@gmail.com**

这是我的代码:

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

                    $SMTP_UserName = "myemail@gmail.com";
                    $SMTP_Password = "****";
                    $from = "myemail@gmail.com";
                    $fromName = "My Name";
                    $to = "destination@gmail.com";

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


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

                    $mail->From     = "myemail@gmail.com";
                    $mail->FromName = "From Name";
                    $mail->AddAddress("myemail@gmail.com");
                    $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;
                    }

我该如何解决?

【问题讨论】:

    标签: php phpmailer


    【解决方案1】:

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

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

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

    它在您的语言文件夹中。或者您可以简单地将您的 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  ?>
    

    【讨论】:

    • 主机上没有“includes/phpMailer/language/”文件夹。我需要创建它吗?
    • 取消注释您的第二行。 //$mail-&gt;SetLanguage('en',dirname(__FILE__) . '/phpmailer/language/');
    • 处理同样的问题。有什么解决办法吗?
    【解决方案2】:

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

    替换

    $mail->IsSMTP();
    

    $mail->Mailer = "mail";
    

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

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        【解决方案4】:

        就这样吧……

        $mail->SetLanguage("en");
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-12-29
          • 2019-06-07
          • 1970-01-01
          • 2012-12-04
          • 1970-01-01
          • 2020-12-18
          • 1970-01-01
          • 2015-09-26
          相关资源
          最近更新 更多