Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

change to server configuration to make this code work

I am using wamp on my desktop computer and trying to send mail()  not phpmailer()
i can send my mail list from sendgrid.com using my desktop computer but I can not regularly use phpmailer and gmail because gmail blocks sometimes

so I need to use mail()

do I have to install smtp server or is there something easier to do
to make this code work  (I do not want to change the code)





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\mail\1.php on line 18

<?php
$subject='subject';
$body='body';
$name='name';
$email='me@gmail.com';
$recipient='me@gmail.com';

$header = "From: ". $name . " <" . $email . ">\r\n";
$header .= "Reply-To: ". $name . " <" . $email . ">\r\n";

$header .= "Return-Path: <".$email.">\n"; 
$header .= "MIME-Version: 1.0\n"; 
$header .= "Content-Type: text/html; charset=ISO-8859-1\n";

$header .= "X-Mailer: PHP/" . phpversion()."\r\n";


mail($recipient, $subject, $body, $header);

?>

Open in new window

SOLUTION
Avatar of Loganathan Natarajan
Loganathan Natarajan
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

still get same warning and no mail received
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\mail\1.php on line 18

I am using a windows desktop computer


from instructions in
http://skylinedesign.co.ke/send-email-from-local-php-wampserver/
and installed sendmail folder

sendmail.ini

smtp_server=mail.mydomain.com
i changed to
smtp_server=localhost


I am using mail()
so do I have to set an email address


php.ini

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = you@yourdomain   ( I did not change this line because I am using mail())

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path ="c:\wamp\sendmail\sendmail.exe -t"    (I added this line)
You will need to change the "sendmail_from" to a valid email account.

Additionally, you may not be able to send email from your desktop computer to the outside world, particularily if you are using a broadband connection.

If you have an account with your local ISP that does not require SMTP authentication then set the "sendmail_from" email address to that address and set the "smtp_server" to the IP address or domain name of your local ISP.

If all you want to do is test, then you install a free email server package and then let your PHP applications send mail in to that.
Avatar of rgb192

ASKER

>>
If you have an account with your local ISP that does not require SMTP authentication then set the "sendmail_from" email address to that address and set the "smtp_server" to the IP address or domain name of your local ISP.

I am using verizon internet
do I use my ip address for "smtp_server"

and which email should I use for "sendmail_from"


>>
If all you want to do is test, then you install a free email server package and then let your PHP applications send mail in to that.

how
For your verizon question:

If you have an email address provided as part of your package with them then you would use that email address in the "sendmail_from" field, and in the "smtp_server" field enter the IP or host name that verizon tells you to use with any desktop mail client (Outlook/Outlook Express/Windows Mail). If however verizon specifies that you should use SMTP Authentication then you will not be able to use this method.

For a standalone mail server:
You could download and install the free Windows email server http://www.hmailserver.com/ and follow the instructions on their website regarding installation. Set up one domain on that email server application, and one account under that domain. Then set hmailserver to allow SMTP connections from "localhost", and then change your PHP.ini file "sendmail_from" field to be that account, and in the "smtp_server" enter "localhost". Then when you use your PHP code to send mail it will go to hmailserver, and you can check the queues to see if your messages are going through correctly.
Avatar of rgb192

ASKER

>> field enter the IP or host name that verizon tells you to use with any desktop mail client (Outlook/Outlook Express/Windows Mail)


is this my ip address when I type 'whatsmyip.com' in my browser
or
is there a verizon ip address for all, and how to find


>>
Then set hmailserver to allow SMTP connections from "localhost"

I cant type localhost, form requires valid domain name
maybe 'gmail.com', 'hotmail.com', 'yahoo.com'
User generated image
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

thanks for
credentials, password

I have a related question about learning smtp

https://www.experts-exchange.com/questions/27851635/linux-smtp-tutorial.html