Programming

Programming Questions? Ask a Programmer for Answers ASAP

Ask a Computer Expert,
Get an Answer ASAP!

Programming

Warning mail() [function.mail] Failed to connect to mailserver at localh

Customer Question
I need to know the...
I need to know the difference between use phpmailer or mail() function in PHP .I tried both , but I got confused now. if I use phpmailer I don't know php.ini works with it.
Submitted: 8 years ago.Category: Programming
Show More
Show Less
Ask Your Own Programming Question
Answered in 8 hours by:
6/29/2009
Programmer: abhi_iitian, Computer Software Engineer replied 8 years ago
abhi_iitian
abhi_iitian, Computer Software Engineer
Category: Programming
Satisfied Customers: 1,757
Experience: B-Tech Topper in CSE from IIT Roorkee, Experience as S/W design Engineer at Microsoft India
Verified
Hi there,

Could you explain the situation a bit ? What are you trying to achieve.. are you tryinng to make a form so that when submitted , information is sent to your email at a website ?

Abhi
Ask Your Own Programming Question
Customer reply replied 8 years ago

So...I have installed wampserver in my computer, so I'm trying t send a email contact form en PHP to any other email company like gmail or yahoo,I'm working in dreamweaver but I don't know exactly how to do this because I got that message.I tried with Phpmailer , :

<?php

/* Subject and Email Variables */

$emailSubject = 'EmailMe!';
$webMaster = '[email protected]';

/* Gathering Data Varibles */

$nameField = $_POST['name'];
$emailField = $_POST['email'];
$phoneField = $_POST['phone'];
$commentsField = $_POST['comments'];

$body = <<<EOD
<br><hr><br>
Name: $nameField <br>
Email: $emailField <br>
Phone Number: $phoneField <br>
Comments: $commentsField <br>
EOD;


$headers = "From: $emailField\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailsubject, $body, $headers);



/* Results rendered as HTML */

$theResults = <<<EOD

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title></head>

<body> [
background-color: #f1f1f1;
font-family: Verdana, Arial,
Helvetica,sans-serif:
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
]
-->
<style>
<head>

<div>
<div align="left">Thank you for your interest your email will be answer very soon</div>
</div>
<body>
<html>
EOD;

echo "$theResults";
?>

Programmer: abhi_iitian, Computer Software Engineer replied 8 years ago

Php needs to know a SMTP address from which it can send emails.

You should have a php.ini file somewhere in your php installation.

At wamp5 (down left) – Config files – php.ini

If you cannot locate that, it will be Most likely at :

C:\wamp\bin\php\php5.2.5\php.ini
C:\wamp\bin\apache\apache2.2.6\bin\php.ini


Look for the following in your PHP.ini file

 

Locate these lines

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25


and paste in your isp SMTP address (this is the one you were given by your ISP for entering into Outlook or Thunderbird):

change "localhost" to your own isp's SMTP address ( the same one you enter in your email program like if you use gmail its smtp.gmail.com and port 587 ) so that it besomes :

[mail function]
; For Win32 only.
SMTP = mail.myisp.net; for Win32 only
smtp_port = 25
[email protected] ; for Win32 only

say for gmail it will become :

SMTP = smtp.gmail.com
smtp_port = 587

Abhi
Ask Your Own Programming Question
Customer reply replied 8 years ago

My configuration Php.ini

 

[mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 587

; For Win32 only.
;sendmail_from = [email protected].

 

Thank you for Reply ...but I had the same error..the point is I would like to send the message to my email gmail or hotmail I dont like use outlook . so let me know please is the correct configuration.

 

Thank you so much, ask for aditional info

 

Eduardo

Programmer: abhi_iitian, Computer Software Engineer replied 8 years ago

You will need sendmail for this, follow the instructions at :

http://digiex.net/guides-tutorials/544-configuring-php-under-windows-use-gmail-external-smtp-server-ssl.html


You can also refer this link(with gmail instead of godaddy.. that is settings required for gmail you can see from above link) :

http://www.joshstauffer.com/tech/send-test-emails-with-wampserver/

If you want to use phpmailer, follow the steps given below(there is no choce to fill the form in that case) :

http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html



Abhi
Ask Your Own Programming Question
Customer reply replied 8 years ago

Hi Abhi:

 

I tried the second option,now is better, no error, but I didn't recieved any email in my account Gmail.

 

Thank you

 

Eduardo

Programmer: abhi_iitian, Computer Software Engineer replied 8 years ago

You mean you used phpmailer ?
Ask Your Own Programming Question
Customer reply replied 8 years ago
Programmer: abhi_iitian, Computer Software Engineer replied 8 years ago

Okay so used that method.. fine.. so you must have these now in sendmail file

  • line 14 | smtp_server=smtp.gmail.com
  • line 18 | smtp_port=587
  • line 38 | [email protected]
  • line 39 | auth_password=yourgmailpassword
Also, in php.ini you should have :

[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25

; For Win32 only.
;sendmail_from [email protected]

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


The mail would be send from your gmail account to te
Ask Your Own Programming Question
Programmer: abhi_iitian, Computer Software Engineer replied 8 years ago

Okay so used that method.. fine.. so you must have these now in sendmail file

  • line 14 | smtp_server=smtp.gmail.com
  • line 18 | smtp_port=587
  • line 38 | [email protected]
  • line 39 | auth_password=yourgmailpassword
Also, in php.ini you should have :

[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25

; For Win32 only.
;sendmail_from [email protected]

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


The mail would be send from your gmail account to the webmaster address , I mean it will be sent to the address you specify in your form by the field $webmaster

Abhi
Ask Your Own Programming Question
Customer reply replied 8 years ago

I did:

; configuration for fake sendmail

; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail

[sendmail]

; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.

smtp_server=smtpout.secureserver.net

; smtp port (normally 25)

smtp_port=80

; SMTPS (SSL) support
; auto = use SSL for port 465, otherwise try to use TLS
; ssl = alway use SSL
; tls = always use TLS
; none = never try to use SSL

;smtp_ssl=auto

; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify

;default_domain=mydomain.com

; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging

error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging

debug_logfile=debug.log

; if your smtp server requires authentication, modify the following two lines

[email protected]
auth_password=2301060

; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines. do not enable unless it is required.

;pop3_server=
;pop3_username=
;pop3_password=

; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify
; the "From: " header of the message content

;force_sender=

; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify
; the "To: " header of the message content

;force_recipient=

; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting. you can manually set the ehlo/helo name if required

hostname=

 

Php.ini:

 

[mail function]
; For Win32 only.
SMTP =
;smtp_port = 587

; For Win32 only.
;sendmail_from =

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

 

Programmer: abhi_iitian, Computer Software Engineer replied 8 years ago
Sorry for the delay.

In the sendmail you do not seem to have entered gmail smtp settings :

smtp_server=smtpout.secureserver.net

; smtp port (normally 25)

smtp_port=80

 

should be

 

  • line 14 | smtp_server=smtp.gmail.com
  • line 18 | smtp_port=587
Ask Your Own Programming Question
Customer reply replied 8 years ago

I'm sorry it doesn't work yet....... have this error log:

 

09/07/01 22:26:48 : Connect timed out.
09/07/01 22:30:19 : Authentication failed.<EOL>
09/07/01 22:44:10 : Message is missing sender's address
09/07/01 22:45:36 : Authentication failed.<EOL>
09/07/05 11:47:30 : Must issue a STARTTLS command first. k37sm25031552rvb.58<EOL>

Customer reply replied 8 years ago

Bebug error in Sendmail:

 

09/07/05 11:47:29 ** --- MESSAGE BEGIN ---
09/07/05 11:47:29 ** To:[email protected]
09/07/05 11:47:29 ** Subject:
09/07/05 11:47:29 ** From:[email protected]
09/07/05 11:47:29 ** Content-type: text/html
09/07/05 11:47:29 **
09/07/05 11:47:29 **
09/07/05 11:47:29 ** <br><hr><br>
09/07/05 11:47:29 ** Name: Edgardo Domingo <br>
09/07/05 11:47:29 ** Email:[email protected] <br>
09/07/05 11:47:29 ** Phone Number: XXXXXXXXX <br>
09/07/05 11:47:29 ** //Spending Plans: <br>
09/07/05 11:47:29 ** //Number of Items: <br>
09/07/05 11:47:29 ** Comments: fdgdfdfghdf <br>
09/07/05 11:47:29 ** //Newsletter: <br>
09/07/05 11:47:29 ** --- MESSAGE END ---
09/07/05 11:47:29 ** Connecting to smtp.gmail.com:587
09/07/05 11:47:30 ** Connected.
09/07/05 11:47:30 << 220 mx.google.com ESMTP k37sm25031552rvb.58<EOL>
09/07/05 11:47:30 >> EHLO Eduardo-PC<EOL>
09/07/05 11:47:30 << 250-mx.google.com at your service, [98.232.101.150]<EOL>250-SIZE 35651584<EOL>250-8BITMIME<EOL>250-STARTTLS<EOL>250-ENHANCEDSTATUSCODES<EOL>250 PIPELINING<EOL>
09/07/05 11:47:30 ** Authenticating [email protected]
09/07/05 11:47:30 >> MAIL FROM: <[email protected]><EOL>
09/07/05 11:47:30 << 530 5.7.0 Must issue a STARTTLS command first. k37sm25031552rvb.58<EOL>
09/07/05 11:47:30 ** Disconnecting from smtp.gmail.com:587
09/07/05 11:47:30 ** Disconnected.
09/07/05 11:47:30 ** Disconnected.
09/07/05 11:47:30 ** Must issue a STARTTLS command first. k37sm25031552rvb.58<EOL>

Programmer: abhi_iitian, Computer Software Engineer replied 8 years ago

The reason for this is that gmail uses secure (TLS) servers to prevent spam.

MAke sure, you have :

smtp_ssl=auto


in sendmail file

If it us there, To solve this problem you need to download the following zip file:
http://glob.com.au/sendmail/sendmail-SSL.zip
and install its contents in the sendmail directory. That will make sendmail.exe TLS compatible.
abhi_iitian
abhi_iitian, Computer Software Engineer
Category: Programming
Satisfied Customers: 1,757
Experience: B-Tech Topper in CSE from IIT Roorkee, Experience as S/W design Engineer at Microsoft India
Verified
abhi_iitian and 87 other Programming Specialists are ready to help you
Ask your own question now
Customer reply replied 8 years ago

Okey I tried with the first and didn't work.....so I have to erase sendmail.exe? and install yours?

Programmer: abhi_iitian, Computer Software Engineer replied 8 years ago

don't erase the earlier one... just unzip the new file and copy the files inside it into existing sendmail directory
Ask Your Own Programming Question
Customer reply replied 8 years ago

Sure!!! Worked.....thank you so much

 

Eduardo

Programmer: abhi_iitian, Computer Software Engineer replied 8 years ago

okay great. Thanks
Ask Your Own Programming Question
Ask abhi_iitian Your Own Question
abhi_iitian
abhi_iitian
abhi_iitian, Computer Software Engineer
Category: Programming
Satisfied Customers: 1,757
1,757 Satisfied Customers
Experience: B-Tech Topper in CSE from IIT Roorkee, Experience as S/W design Engineer at Microsoft India

abhi_iitian is online now

A new question is answered every 9 seconds

How JustAnswer works:

  • Ask an ExpertExperts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional AnswerVia email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction GuaranteeRate the answer you receive.

JustAnswer in the News:

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed.

One Happy CustomerNew York

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help.

Mary C.Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!

AlexLos Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.

GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

JustinKernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around.

EstherWoodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know.

RobinElkton, Maryland

< Previous | Next >

Meet the Experts:

ATLPROG

ATLPROG

Computer Software Engineer

7,677 satisfied customers

MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML

LogicPro

LogicPro

Computer Software Engineer

7,131 satisfied customers

Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.

unvadim

unvadim

Computer Software Engineer

1,168 satisfied customers

Good knowledge of OOP principles. 3+ years of programming experience with Java and C++. Sun Certified Java Programmer 5.0.

lifesaver

lifesaver

Computer Software Engineer

950 satisfied customers

Several years of intensive programming and application development experience in various platforms.

ehabtutor

ehabtutor

Computer Software Engineer

936 satisfied customers

Bachelor of computer science, 5+ years experience in software development, software company owner

TheDoctor

TheDoctor

Software Engineer

893 satisfied customers

M.S. in Internet Information Systems

The-PC-Guy

The-PC-Guy

Software Engineer

800 satisfied customers

Extensive Knowledge in PHP, MYSQL, CSS & Javascript

< Previous | Next >

Related Programming Questions
Nothing is going on with my computer, but I need some help
Nothing is going on with my computer, but I need some help with excel can you help … read more
Richard
Richard
IT Manager
IT Manager, Consultant
3,281 satisfied customers
My account was seriously hacked. I bought a new phone it was
My account was seriously hacked. I bought a new phone it was so bad. To my surprise they apparently set up a fake FB account. Now I cannot get into my account. The account it keeps pulling up is not m… read more
Pete
Pete
Engineer
Bachelor\u0027s Degree
1,124 satisfied customers
My Microsoft Word and Excel app now require Office 365. They
My Microsoft Word and Excel app now require Office 365. They didn't when I installed the apps. I have them linked to Dropbox files. ???? … read more
Jinsmn
Jinsmn
Systems Administrator
Diplom
1,260 satisfied customers
I am new to word press and downloaded the wordpress.org and
i am new to word press and downloaded the wordpress.org and paid for the business plan and hosted by Bluehost I purchased a theme for Buz theme called the-multiple-pro which they sent a zip file I sep… read more
Chris L.
Chris L.
IT/Web Manager
Vocational, Technical or Trade Scho
29 satisfied customers
I want to pass a csv file twice. The first pass works
I want to pass a csv file twice. The first pass works perfectly: LAreader = csv.reader(open(InFileName,'r')) for line in LAreader: SvcDepNamesSet.add (line[0].strip())When I try a second time, there i… read more
George Sibiya
George Sibiya
PhD
217 satisfied customers
Can I ask you about this question At Olympic diving
Hi Can I ask you about this question At Olympic diving competition level, 10 diving judges award At Olympic diving competition level, 10 diving judges award a single mark (with one decimal place) for … read more
LogicPro
LogicPro
Computer Software Engineer
Bachelor of Technology
7,131 satisfied customers
I have had a mailing list in excel (personal) for years. Can
I have had a mailing list in excel (personal) for years. Can you help me find it so I can update it?? … read more
Sheri
Sheri
Bachelor\u0027s Degree
105 satisfied customers
I need to design an antisense oligo against beta catenin and
I need to design an antisense oligo against beta catenin and HCV-related sequences for clinical use … read more
Kris R
Kris R
IT Manager
Computing
2,652 satisfied customers
I need to know how to create and move a stack of playing
I need to know how to create and move a stack of playing cards in visual basic … read more
Ingo U
Ingo U
Master\u0027s Degree
357 satisfied customers
Write a C++ program to read in various types of test
Write a C++ program to read in various types of test questions (multiple choice and True/False) from a test bank (text file), and load the questions into an array of questions. You will need to implem… read more
LogicPro
LogicPro
Computer Software Engineer
Bachelor of Technology
7,131 satisfied customers
I want to copy a formula horizontally across a row and can't
I want to copy a formula horizontally across a row and can't get it to repeat … read more
The-PC-Guy
The-PC-Guy
Software Engineer
Bachelor's Degree
800 satisfied customers
I'm trying to make a python object oriented checkers game,
I'm trying to make a python object oriented checkers game, but I'm lost. I'm trying to find a source code for a python checkers game. Is there any way you would be able to help me … read more
George Sibiya
George Sibiya
PhD
217 satisfied customers
I have a spreadsheet with customer sales and market
I have a spreadsheet with customer sales and market information for the first half of 2017. The list has over 10,000 rows. I added the market segment manually from a drop down menu. Very time consumin… read more
The-PC-Guy
The-PC-Guy
Software Engineer
Bachelor's Degree
800 satisfied customers
Not sure how to explain this...but I have an excel report
Hi! Not sure how to explain this...but I have an excel report with a field name for first name and one for last name. The report contains multiple people from the same household, one row for each. Eac… read more
The-PC-Guy
The-PC-Guy
Software Engineer
Bachelor's Degree
800 satisfied customers
Wanting to insert function into a invoice I am building on
wanting to insert function into a invoice I am building on excel, how to add a subtraction … read more
The-PC-Guy
The-PC-Guy
Software Engineer
Bachelor's Degree
800 satisfied customers
How do I get my restored Microsoft Wordpad .rtf files to
How do I get my restored Microsoft Wordpad .rtf files to stop coming up in Landscape orientation. I want them to normally come up in Portrait orientation? (Tech Viet helped me a few days ago.)… read more
Elgin Vega
Elgin Vega
Science Bachellor
104 satisfied customers
I am looking for help understanding the content of some
Hi. I am looking for help understanding the content of some files. Ideally, I could have someone explain what certain things mean so that I am not making assumptions. The files are in HTML, JS, SQL, a… read more
George Sibiya
George Sibiya
PhD
217 satisfied customers
Searching for a tutorial on WordPress theme ColorMag Pro -
Searching for a tutorial on WordPress theme ColorMag Pro - some I have found have no sound and or the narration isn't understandable. … read more
RussellA
RussellA
Solutions Architect
Bachelor\u0027s Degree
123 satisfied customers
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Show MoreShow Less

Ask Your Question

x