如何从本地主机发送电子邮件WAMP服务器发送电子邮件Gmail Hotmail等


How to send email from localhost WAMP Server to send email Gmail Hotmail or so forth?

我正在寻找关于如何从本地主机WAMP发送电子邮件的适当信息。以及如何获得从特定授权电子邮件地址发送电子邮件的授权,以发送任何其他电子邮件地址。

如何配置这整个步骤解释我的细节,我已经访问了这里一些堆栈溢出的答案以及博客文章,但都是非常令人困惑和陈旧的,所以它可能不工作。所以我需要堆栈溢出用户的帮助。谢谢你!

localhost配置一个工作的电子邮件客户端是相当苦差事,我花了几个小时的挫折尝试它。最后我找到了这样的方式来发送邮件(使用WAMP, XAMPP等):

安装hMailServer

配置hMailServer设置:

    打开hMailServer Administrator.
  1. 点击"Add domain…"按钮创建新域。
  2. 在域文本字段下,输入计算机的本地主机IP。
    • 示例:127.0.0.1是您的本地主机IP。
    • 点击"保存"按钮。
    • 现在转到设置>协议> SMTP,选择"发送电子邮件"选项卡。
    • 查找localhost字段输入"localhost"
    • 点击保存按钮。

    配置您的Gmail帐户,执行以下修改:

    1. 进入设置>协议> SMTP,选择"发送邮件"选项卡。
    2. 在远程主机名字段中输入"smtp.gmail.com"。
    3. 输入"465"作为端口号
    4. 检查"Server requires authentication"
    5. 在Username字段中输入您的Google Mail地址。
    6. 在密码栏输入您的Google Mail密码。
    7. 勾选"使用SSL"
    8. 保存所有更改

    可选

    如果您想从另一台计算机发送电子邮件,您需要通过以下步骤允许从外部帐户到外部帐户的交付:

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

    For me Fake Sendmail works

    怎么做:

    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"
    

    就是这样。现在可以测试邮件了。

    尝试在WAMP环境中使用fake sendmail发送电子邮件。

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

    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");
    
    信贷

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

    另一种方式

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

    两者都支持SSL下的SMTP认证

    Credit:此处查看参考答案

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

      首先,你需要下载Sendmail zip文件链接解压zip文件并放到C:'wamp目录下现在,您需要在C:'wamp'sendmail'sendmail.ini 上编辑Sendmail.ini
    smtp_server=smtp.gmail.com 
    smtp_port=465
    auth_username=user@gmail.com
    auth_password=your_password
    
  3. 访问您的电子邮件帐户。点击齿轮工具>设置>转发和POP/IMAP> IMAP访问。单击"启用IMAP",然后save your changes
  4. 运行WAMP服务器在Apache Module下启用ssl_module。
  5. 下一步,在PHP下启用php_openssl和php_sockets。**现在最重要的部分是在"C:'wamp'bin'php'php5.5.12'php.ini"上打开php.ini文件"C:'wamp'bin'apache'apache2.4.9'bin'php.ini" set sendmail_path **
  6. sendmail_path = "C:'wamp'sendmail'sendmail.exe -t"

  7. 重启Wamp服务器
  8. 一定会成功的。

    这是使用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);
        }
    

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

    click below for mail sending code
    

    点击这里

    听着,伙计们,首先你可以这样做更少的安全您的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....
    

    如果您有一个不发送电子邮件的wamp设置,那么只有几件事要做。1. 找出您的isp的SMTP服务器名称。gmail的事情很可能是不必要的复杂2. 在你的"www"文件夹中创建一个php .php文件,然后像这样编辑:

    <?php
       phpinfo();
    ?>
    

    这将告诉您wamp正在使用什么。3.搜索php.ini文件。可能有好几个。您想要的是影响上述文件输出的那个。4. 在最有可能的php.ini中找到SMTP地址。5. 在浏览器中输入localhost/php .php并向下滚动到smtp设置。应该是localhost6. 编辑php.ini文件smtp设置为您的isp smtp服务器的名称。检查它是否为您更改php. php。如果它工作,你完成了,如果不是,你是错误的文件。

    这个问题应该出现在Wordpress网站上,但是他们太自负了,或者试图获得客户端。;)