Jump to content

mail() function is not going through


co.ador

Recommended Posts

I got this warning after using the mail function. It seem not to be configure at the php.ini does anybody has any idea on how to fix it.

 

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\step2.php on line 14

 

Help please...

Link to comment
Share on other sites

this is how the mail function is configure at php.ini

 

[mail function]

; For Win32 only.

SMTP = localhost

smtp_port = 25

 

; For Win32 only.

sendmail_from = you@yourdomain

 

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").

;sendmail_path =

Link to comment
Share on other sites

I don't know thorpe how can I find out the mail server set up on localhost?

 

WAMP = Windows Apache MySQL & PHP, To my knowledge an SMTP server would not be installed along with it. You'd need to install it separately or use a paid hosting's account.

 

EDIT: If you really wanted to find out if you had it or not, Go into command line and type "telnet 127.0.0.1 25", and if it does not connect there's nothing accepting the SMTP port.

Link to comment
Share on other sites

I am getting the same error still, Can't get to configure the DNS server in my localhost.

 

using this in the script to configure my php.ini

<?php //set SMTP in php.ini
ini_set("SMTP", "smtp.gmail.com");?>

 

The php.ini configuration is

 

[mail function]

; For Win32 only.

SMTP = localhost

smtp_port = 25

 

; For Win32 only.

sendmail_from = mail.stores.com

 

 

but it is bringing a warning

 

 

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

 

Can ask my host provider for the DNS server, or am I missing something else in the code?

 

I have used the toturial below and he talks about getting an DNS server, or ISP but I don't know where to find those tools to make it work. I have asked my domain host server and they give me mail.domainname.com as the DNS server but that's what I need for this purpose?

 

http://www.youtube.com/watch?v=xHbiPDSX9so&feature=related

Link to comment
Share on other sites

A DNS server is a 'domain name server', not at all what you need.

 

Easiest way to use gmail as your mail server on a local box (providing it is a Linux box) is to install and configure ssmtp. ssmtp will emulate sendmail and allow you to use remote smtp servers (like gmail provide).

 

Otherwise, you might want to look into using a mail class like PHPMailer as php's default mail() function has not way of sending authentication which is usually required by remote mail servers.

Link to comment
Share on other sites

one of the easiest way to send mail is to download PHP Mailer and then  ...this file will be able to send the mail.....

place this file in the phpmailer folder and wen this file is executed,u will be able to send the mail :)

 

<?

//require("phpmailer/class.phpmailer.php");

include("class.phpmailer.php");

include("class.smtp.php");

$mail = new PHPMailer();

$mail->IsSMTP(); // send via SMTP

//IsSMTP(); // send via SMTP

$mail->Host = "ssl://smtp.gmail.com"; // specify main and backup server

$mail->Port = 465; // set the port to use

$mail->SMTPAuth = true; // turn on SMTP authentication

$mail->Username = "urmailid@gmail.com"; // SMTP username

$mail->Password = "password"; // SMTP password

$webmaster_email = "urmailid@gmail.com"; //Reply to this email ID

$email="recipientsmailid"; // Recipients email ID

$name="recipients name"; // Recipient's name

$mail->From = $webmaster_email;

$mail->FromName = "Webmaster";

$mail->AddAddress($email,$name);

$mail->AddReplyTo($webmaster_email,"Webmaster");

$mail->WordWrap = 50; // set word wrap

//;$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment

//;$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment

$mail->IsHTML(true); // send as HTML

$mail->Subject = "This is the subject";

$mail->Body = "Hi,

This is the HTML BODY "; //HTML Body

$mail->AltBody = "This is the body when user views in plain text format"; //Text Body

if(!$mail->Send())

{

echo "Mailer Error: " . $mail->ErrorInfo;

}

else

{

echo "Message has been sent";

}

?>

Link to comment
Share on other sites

that's a statement based on the to previous post. my php.ini is configure in port 25 and it was not working. Even though i have change it. I was trying to use a google dns server but having the port on 25 and not realizing i had to set it to 465. I have also realize that in the local host some extra work is needed in the php.ini but no in the host server which a configuration of php.ini is not needed.

Link to comment
Share on other sites

You keep mentioning DNS servers. DNS servers resolve domain names, they do not send email.

 

Gmail requires an authenticated user in order to send email so simply changing ports and pointing to Gmail is not sufficient. See my post here.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.