• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 607
  • Last Modified:

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

0
rgb192
Asked:
rgb192
  • 4
  • 3
2 Solutions
 
Loganathan NatarajanLAMP DeveloperCommented:
You could send mail using smtp configuration. check out this link
0
 
rgb192Author Commented:
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)
0
 
grahamnonweilerCommented:
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.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
rgb192Author Commented:
>>
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
0
 
grahamnonweilerCommented:
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.
0
 
rgb192Author Commented:
>> 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'
what data to enter in form field
0
 
grahamnonweilerCommented:
On the assumption you are using a consumer (broadband) Internet connection:


Re: >> field enter the IP or host name that verizon tells you to use with any desktop mail client

Talk to your ISP, ask them how you can send email - most ISPs allow you to send email without Authentication. If they tell you that you need to use Authentication then you do not need to know the IP address as you can not configure PHP to use Authentication natively.


Re: Hmail setup

In the screenshot you are setting up a default domain for Hmail to work with - enter the domain name for the PHP scripts you are trying to debug. For instance "mycompany.com"

The reference to "localhost" that I gave was in reference to security settings, where you would setup Hmail to "allow" connections from "localhost" or 127.0.0.* - then PHP will not need to use authentication.

In conclusion, an observation:

It seems from this post (as well as a number of other posts you have here on EE) that you are possibly trying to do too much without fully understanding the technology and standards that are required to support what you are trying to achieve.

In this particular case you need to understand the SMTP mail transport layer, and if you are going to attempt to use Hmail, you also need to understand the basics of how email servers work in general.

If you start sending SMTP messages from your desktop setup, across the Internet, using someone's FQDN (domain name), then you stand the chance of getting that domain added to various black lists which could ultimately cause the owner of that domain name (assuming its not you) harm.

I would advise you to research and learn a little more about how email works, and particularly research how you could setup a "local" domain for your testing purposes.

While EE is an excellent place to find solutions to problems you are facing - it should not be used in place of "tutorials" or genuine learning methods.
0
 
rgb192Author Commented:
thanks for
credentials, password

I have a related question about learning smtp

http://www.experts-exchange.com/OS/Linux/Q_27851635.html
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now