如何从localhost WAMP Server发送电子邮件以发送电子邮件Gmail Hotmail等?

时间:2014-03-14 05:17:36

标签: php email localhost wamp

我找到了有关如何从localhost WAMP发送电子邮件的正确信息。以及如何授权从特定授权电子邮件地址发送电子邮件以发送任何其他电子邮件地址。

如何配置这整个步骤解释我的详细信息,我已经在这里访问了一些Stack Overflow的答案以及博客文章,但所有这些都非常令人困惑和过时,所以它可能无法正常工作。所以我需要Stack Overflow用户帮助。谢谢。

8 个答案:

答案 0 :(得分:18)

localhost配置一个有效的电子邮件客户端是一件非常繁琐的工作,我花了几个小时的努力尝试它。最后我发现这种方式发送邮件(使用WAMP,XAMPP等):

安装hMailServer

配置此hMailServer设置:

  1. 打开hMailServer Administrator。
  2. 点击“添加域...”按钮以创建新域。
  3. 在域文本字段下,输入您计算机的localhost IP。
    • 示例:127.0.0.1是您的localhost IP。
  4. 点击“保存”按钮。
  5. 现在转到设置>方案> SMTP并选择“电子邮件递送”选项卡。
  6. 找到localhost字段,输入“localhost”。
  7. 点击“保存”按钮。
  8. 配置您的Gmail帐户,执行以下修改:

    1. 转到设置>方案> SMTP并选择“电子邮件递送”选项卡。
    2. 在远程主机名字段中输入“smtp.gmail.com”。
    3. 输入“465”作为端口号。
    4. 选中“服务器要求身份验证”。
    5. 在“用户名”字段中输入您的Google Mail地址。
    6. 在密码字段中输入您的Google Mail密码。
    7. 选中“使用SSL”
    8. 保存所有更改。

    9. 可选

      如果您想从另一台计算机发送电子邮件,您需要按照以下步骤从外部帐户到外部帐户进行交付:

      1. 转到设置>高级> IP范围并双击“我的电脑”     应该有IP地址127.0.0.1
      2. 选中允许从外部帐户交付到外部帐户复选框。
      3. 使用“保存”按钮保存设置。

答案 1 :(得分:8)

对我来说Fake Sendmail有效。

该怎么做:

1)修改C:\wamp\sendmail\sendmail.ini:

smtp_server=smtp.gmail.com
smtp_port=465
auth_username=user@gmail.com
auth_password=your_password

2)修改php.ini并设置sendmail_path

sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"

那就是它。现在你可以测试邮件了。

答案 2 :(得分:3)

尝试使用假的sendmail在SWAMP环境中发送电子邮件。

http://jesin.tk/using-sendmail-on-windows/

答案 3 :(得分:2)

a) Open the "php.ini". For XAMPP,it is located in C:\XAMPP\php\php.ini. Find out if you are using WAMP or LAMP server. Note : Make a backup of php.ini file 

b) Search [mail function] in the php.ini file. 

You can find like below.
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25


; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost


Change the localhost to the smtp server name of your ISP. No need to change the smtp_port. Leave it as 25. Change sendmail_from from postmaster@localhost to your domain email address which will be used as from address.. 

So for me, it will become like this.
[mail function]
; For Win32 only.
SMTP = smtp.planetghost.com
smtp_port = 25
; For Win32 only.
sendmail_from = info@planetghost.com
auth_username = example_username@example.com
auth_password = example_password


c) Restart the XAMPP or WAMP(apache server) so that changes will start working.

d) Now try to send the mail using the mail() function , 

mail("abc@gmail.com","Success","Great, Localhost Mail works");

credit

=============================================== =================================

另一种方式

Gmail服务器在SSL下使用SMTP身份验证。我认为在这种情况下无法使用mail()函数,因此您可能需要检查这些替代方法:

  1. PEAR: Mail
  2. phpMailer
  3. 他们都支持SSL下的SMTP身份验证。

    信用:Check reference answer here

答案 4 :(得分:0)

这是使用PHPmailer库发送电子邮件的最佳方式,这是唯一适用于我的方法。

require_once 'mailer/class.phpmailer.php';
    $mail = new PHPMailer(); // create a new object
    $mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true; // authentication enabled
    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 465; // or 587
    $mail->IsHTML(true);
    $mail->Username = "xxxxxx@gmail.com";
    $mail->Password = "xxxxxxx";
    $mail->SetFrom("xxxx@xxx.com");
    $mail->AddAddress($to);
    $logfile = dirname(dirname(__FILE__)) . '/mail.log';
    try {
        $mail->Body = $message;
        $mail->Subject = $subject;


        file_put_contents($logfile, "Content: \n", FILE_APPEND);
        file_put_contents($logfile, $message . "\n\n", FILE_APPEND);

        if(!$mail->Send()) {
            echo "Mailer Error: " . $mail->ErrorInfo;
        } else {
            echo "Email has been sent";
        }
    } catch (Exception $e) {
        #print_r($e->getMessage());
        file_put_contents($logfile, "Error: \n", FILE_APPEND);
        file_put_contents($logfile, $e->getMessage() . "\n", FILE_APPEND);
        file_put_contents($logfile, $e->getTraceAsString() . "\n\n", FILE_APPEND);
    }

答案 5 :(得分:0)

以下是wamp服务器使用Sendmail从localhost发送电子邮件的步骤。

  1. 首先,您需要下载Sendmail zip文件link
  2. 解压缩zip文件并将其放在C:\ wamp
  3. 现在,您需要在C:\wamp\sendmail\sendmail.ini
  4. 上修改 Sendmail.ini
    smtp_server=smtp.gmail.com 
    smtp_port=465
    auth_username=user@gmail.com
    auth_password=your_password
    
    1. 访问您的电子邮件帐户。单击Gear Tool>设置> 转发和POP / IMAP> IMAP访问。单击“启用IMAP”,然后 保存更改
    2. 运行您的WAMP服务器。在Apache Module下启用ssl_module。
    3. 接下来,在PHP下启用php_openssl和php_sockets。
    4. **现在重要部分在"C:\wamp\bin\php\php5.5.12\php.ini"上打开 php.ini 文件 "C:\wamp\bin\apache\apache2.4.9\bin\php.ini"设置 sendmail_path **
    5.   

      sendmail_path =“C:\ wamp \ sendmail \ sendmail.exe -t”

      1. 重启Wamp Server。
      2. 肯定会奏效。

答案 6 :(得分:0)

没有任何SMTP服务器发送邮件,请使用此代码发送邮件....

click below for mail sending code

Click here

首先听听你们用gmail帐户发送邮件后你可以做安全性低于gmail帐户

您可以使用此php.ini设置

;smtp = smtp.gmail.com
;smtp-port = 25
;sendmail_from = my gmail is here

和sendmail.ini设置

smtp_server = smtp.gmail.com
smtp_port = 465
smtp_ssl = auto
auth_username = my gmail is here
auth_password = password
hostname = localhost

you can try this changes and i hope this code sent mail....

答案 7 :(得分:0)

如果你有一个不会发送电子邮件的wamp设置,那么只有几件事要做。 1.找出你的isp的smtp服务器名称是什么。 gmail很可能是不必要的复杂问题 2.在你的' www中创建一个phpsetup.php文件。文件夹和编辑如下:

<?php
   phpinfo();
?>

这将为您提供有关wamp正在使用的内容的句柄。 3.搜索php.ini文件。可能有几个。你想要的是影响上面文件输出的那个。 4.在最有可能的php.ini中找到smtp地址。 5.在浏览器中键入localhost / phpsetup.php并向下滚动到smtp设置。它应该说“localhost”#39; 6.将php.ini文件smtp设置编辑为ISPs smtp服务器的名称。 检查它是否为您改变了phpsetup.php。如果它完成了你的工作,如果没有你正在使用错误的文件。

这个问题应该在Wordpress网站上,但它们太过于自我或者试图吸引客户。;)

相关问题