Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending emails with WAMP

Tags:

php

email

I use the latest WAMP and I get this when I try to send emails:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\main\createaccount.php on line 8

Message delivery failed...

The message:

$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }

Do you need do download a "mailserver" also?

Please help.

like image 349
Jorm Avatar asked Jan 02 '10 22:01

Jorm


People also ask

Can I send email from localhost?

You can send mail from localhost with sendmail package , sendmail package is inbuild in XAMPP. So if you are using XAMPP then you can easily send mail from localhost. For example, you can configure C:\xampp\php\php. ini and c:\xampp\sendmail\sendmail.

Can I send email from localhost PHP?

Send Email from Localhost with PHPSet SMTP credentials (host, username, password, and port). Specify sender name and email ( $mail->setFrom ). Set recipient email address ( $mail->addAddress ). Set email subject ( $mail->Subject ).

Where is Sendmail INI in WAMP?

Open the sendmail. ini file located in “c:\wamp64\sendmail\sendmail. ini”. Search for [sendmail] by pressing ctrl + f.


1 Answers

This works for me and should work for you: Use Fake Sendmail and a webhost mail server (i.e. - Godaddy, 1and1, etc.).

1.) Download the sendmail zip and extract it to C:\Wamp\bin\sendmail (for purposes of this example).

2.) Edit C:\wamp\bin\sendmail\sendmail.ini and set the following to your mail server's requirements (mine are below):

smtp_server=mail.yourdomain.com
smtp_port=26
smtp_ssl=none
;default_domain=yourdomain.com
[email protected]
auth_password=smtppassword
;pop3_server=
;pop3_username=
;pop3_password=
;force_sender=
;force_recipient=

3.) Set the path of sendmail.exe in your php.ini file.

[mail function]
; For Win32 only.
SMTP =

; For Win32 only.
sendmail_from =

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:\wamp\bin\sendmail\sendmail.exe -t"

4.) Restart Wampserver.

You might have success using Gmail, but there are a few extra tweaks to make it work. I prefer using the mail server of the webhost where I upload my code.

like image 196
Josh Avatar answered Sep 29 '22 09:09

Josh