Jump to content

Recommended Posts

Hi All,

 

I am facing a problem which I am not able to solve even after googling for quite some time. So if you could help me, I would be very grateful.

 

I am trying to email using mail() function. I installed "Free SMTP Server" and it is up running. I have following code:-

 

        $message = 'Hi There';

        $header = 'From: myemail@gmail.com';                    //From header is must

        $subject = "Feedback Form Results";

        $send=mail("myemail@gmail.com", $subject, $message, $header) or die("failure");

 

However, I get following error:-

 

Warning: mail() [function.mail]: SMTP server response: 550 Invalid recipient: myemail@gmail.com

 

My php.ini has following:-

[mail function]

; For Win32 only.

; http://php.net/smtp

SMTP = localhost

; http://php.net/smtp-port

smtp_port = 25

 

; For Win32 only.

; http://php.net/sendmail-from

sendmail_from = you@yourdomain

 

I am using WAMP server to test the website locally.

 

I am lost here and not sure what is going wrong. It is very important for me to code this email function correctly, but I am not able to. I am looking for your ideas and help.

 

Thanks a lot!

Priya

 

hai priya

dont u need to change your local domain sendmail_from = you@yourdomain to send a mail.and also can u check whether u have the port 21 opened in ur machine...one more thing as per ur error wht u are having might be it cannot able to connect to ur domain server which u have given. check whether u have mail server configured properly

        $message = 'Hi There';

        $header = 'From: myemail@gmail.com';                    //From header is must

        $subject = "Feedback Form Results";

        $send=mail("myemail@gmail.com", $subject, $message, $header) or die("failure");

Try adding the -f parameter to your mail() function like so:

        $message = 'Hi There';
        $header = 'From: myemail@gmail.com';                    //From header is must
        $subject = "Feedback Form Results";
        $send=mail("myemail@gmail.com", $subject, $message, $header, '-fmyemail@gmail.com');

No space between the -f and 'from' e-mail address forced. Also note that port 21 HAS to be opened, it's an invalid recipient if it's not reachable!

 

EDIT: You cannot use or Die on a variable. Write:

if (!$send) { die('Mail error'); }

Thank you all for your suggestions. But I still get the same error. My php_ini has 25 as SMTP port. I checked using helo in telnet to localhost at 25, and it replied back with "Hello localhost". So I think port 25 is open.

 

I also changed sendmail_from = me@localhost, but it is still not working. Please tell me if my syntax is wrong.

 

Thanks again a lot in advance.

 

Priya

Hi ym_chaitu,

 

Here is my code:-

 

        ini_set("SMTP","smtp.utah.edu");

        ini_set("sendmail_from","u0123456@utah.edu");

 

        $message = 'Hi There';

        $header = 'From: u0123456@utah.edu';                   

        $subject = "Feedback Form Results";       

        $send=mail("u0123456@utah.edu", $subject, $message, $header);

 

Thanks for taking the time to help me out here. smtp.utah.edu is the mail server.

 

The error I am getting is:-

Warning: mail() [function.mail]: Failed to connect to mailserver at "smtp.utah.edu" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

 

Priya

If on localhost it could be that your ISP blocks port 25 (which is common among most cable providers). Verify that your ISP does or does not block Port 25. If they do, there really is not away around that other than find a smtp host that does not use Port 25.

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.