wp_mail不工作的本地主机与甲基苯丙胺(wp_mail not working on local

2019-10-19 12:38发布

我试图让wp_mail功能给自己发送电子邮件,由于某种原因,我不能得到它的工作。 任何人都可以帮助我吗?

这是我的基本的脚本...

$to = "someone@gmail.com";
$subject = 'wp_mail function test';
$message = 'This is a test of the wp_mail function: wp_mail is working';
$headers = "From: Blog Name <admin@myemail.com> \r\n";

if ( $sent = wp_mail( $to, $subject, $message, $headers ) )
    echo 'The test message was sent. Check your email inbox.';
else
    echo 'The message was not sent!';

如果我的var_dump($ PHPMailer的)然后我得到以下...

object(PHPMailer)[288]
  public 'Priority' => int 3
  public 'CharSet' => string 'UTF-8' (length=5)
  public 'ContentType' => string 'text/plain' (length=10)
  public 'Encoding' => string '8bit' (length=4)
  public 'ErrorInfo' => string '' (length=0)
  public 'From' => string 'admin@myemail.com' (length=17)
  public 'FromName' => string 'Blog Name' (length=9)
  public 'Sender' => string '' (length=0)
  public 'ReturnPath' => string '' (length=0)
  public 'Subject' => string 'wp_mail function test' (length=21)
  public 'Body' => string 'This is a test of the wp_mail function: wp_mail is working' (length=58)
  public 'AltBody' => string '' (length=0)
  protected 'MIMEBody' => string 'This is a test of the wp_mail function: wp_mail is working
' (length=59)
  protected 'MIMEHeader' => string 'Date: Fri, 7 Mar 2014 15:19:55 +0000
Return-Path: admin@myemail.com
From: Blog Name <admin@myemail.com>
Message-ID: <ebf10bab4b57a811f54fe004e70a5a73@tp.dev>
X-Priority: 3
X-Mailer: PHPMailer 5.2.4 (http://code.google.com/a/apache-extras.org/p/phpmailer/)
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8
' (length=346)
  protected 'mailHeader' => string 'To: someone@gmail.com
Subject: wp_mail function test
' (length=53)
  public 'WordWrap' => int 0
  public 'Mailer' => string 'mail' (length=4)
  public 'Sendmail' => string '/usr/sbin/sendmail' (length=18)
  public 'UseSendmailOptions' => boolean true
  public 'PluginDir' => string '' (length=0)
  public 'ConfirmReadingTo' => string '' (length=0)
  public 'Hostname' => string '' (length=0)
  public 'MessageID' => string '' (length=0)
  public 'MessageDate' => string '' (length=0)
  public 'Host' => string 'localhost' (length=9)
  public 'Port' => int 25
  public 'Helo' => string '' (length=0)
  public 'SMTPSecure' => string '' (length=0)
  public 'SMTPAuth' => boolean false
  public 'Username' => string '' (length=0)
  public 'Password' => string '' (length=0)
  public 'AuthType' => string '' (length=0)
  public 'Realm' => string '' (length=0)
  public 'Workstation' => string '' (length=0)
  public 'Timeout' => int 10
  public 'SMTPDebug' => boolean false
  public 'Debugoutput' => string 'echo' (length=4)
  public 'SMTPKeepAlive' => boolean false
  public 'SingleTo' => boolean false
  public 'SingleToArray' => 
    array (size=0)
      empty
  public 'LE' => string '
' (length=1)
  public 'DKIM_selector' => string '' (length=0)
  public 'DKIM_identity' => string '' (length=0)
  public 'DKIM_passphrase' => string '' (length=0)
  public 'DKIM_domain' => string '' (length=0)
  public 'DKIM_private' => string '' (length=0)
  public 'action_function' => string '' (length=0)
  public 'Version' => string '5.2.4' (length=5)
  public 'XMailer' => string '' (length=0)
  protected 'smtp' => null
  protected 'to' => 
    array (size=1)
      0 => 
        array (size=2)
          0 => string 'someone@gmail.com' (length=17)
          1 => string '' (length=0)
  protected 'cc' => 
    array (size=0)
      empty
  protected 'bcc' => 
    array (size=0)
      empty
  protected 'ReplyTo' => 
    array (size=0)
      empty
  protected 'all_recipients' => 
    array (size=1)
      'someone@gmail.com' => boolean true
  protected 'attachment' => 
    array (size=0)
      empty
  protected 'CustomHeader' => 
    array (size=0)
      empty
  protected 'message_type' => string 'plain' (length=5)
  protected 'boundary' => 
    array (size=3)
      1 => string 'b1_ebf10bab4b57a811f54fe004e70a5a73' (length=35)
      2 => string 'b2_ebf10bab4b57a811f54fe004e70a5a73' (length=35)
      3 => string 'b3_ebf10bab4b57a811f54fe004e70a5a73' (length=35)
  protected 'language' => 
    array (size=0)
      empty
  protected 'error_count' => int 0
  protected 'sign_cert_file' => string '' (length=0)
  protected 'sign_key_file' => string '' (length=0)
  protected 'sign_key_pass' => string '' (length=0)
  protected 'exceptions' => boolean true    

它总是说,发送电子邮件还没有电子邮件永远到达。

希望可以有人帮帮我!!!

Answer 1:

我总是用WP邮件的SMTP插件并配置它通过在本地主机上,然后当我移动到生产,我只是删除插件我的Gmail帐户发送电子邮件。



Answer 2:

Unfotunately,所有的PHP邮件功能不localhost上工作...

由于SMTP服务器不存在于服务器,本地主机...

我建议ü下载一个SMTP服务器乌尔localhost来使用WP-邮件



Answer 3:

我得到这个工作在按照以下指南MAMP。

http://benjaminrojas.net/configuring-postfix-to-send-mail-from-mac-os-x-mountain-lion/



Answer 4:

使用XAMPP与内置的,sendmail的包。

在php.ini中找到extension=php_openssl.dll并删除分号启用SSL,那么

在php.ini中找到[mail function]

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

然后在XAMPP找到\sendmail\sendmail.ini

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=gmail_id@gmail.com
auth_password=gmail-password
force_sender=gmail_id@gmail.com

这样做,你可以从本地主机通过Gmail发送邮件...



文章来源: wp_mail not working on localhost with MAMP