Language string failed to load: from_failed[from_email_address]

被刻印的时光 ゝ 提交于 2019-12-01 03:11:37

问题


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

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

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 = "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;
                    }

How can I fix it?


回答1:


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

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 SetLanguage method to this source:

  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  ?>



回答2:


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.

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.




回答3:


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



来源:https://stackoverflow.com/questions/9109261/language-string-failed-to-load-from-failedfrom-email-address

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!