PDA

View Full Version : PHP SMTP_port. . . huh?



Jas
12-06-2007, 10:20 PM
Here is the type of error I am getting:

Warning: mail() [function.mail]: Failed to connect to mailserver at "MyDomain" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in PATH on line 37

So what should it be? I am running an XP server with PHP5. Do I need some kind of emailing client-- such as in the case of FTP? Or do I have a setting wrong? What am I suppose to do?

BTW: I am using the ini_set() function to control the settings for now. I don't think that makes a differense, but I thought I would mention it.

thetestingsite
12-06-2007, 10:22 PM
You have to have a functioning mail server installed in order to send emails on your home server. I recommend hMailServer (http://www.hmailserver.com) as it is really easy to use and is free.

Hope this helps.

Jas
12-06-2007, 10:43 PM
Thanks for the quick reply. Now I am getting this:


Warning: mail() [function.mail]: SMTP server response: 550 The address is not valid. in PATH on line 37

What does that mean?

BTW: I am sending an email to the user-- a registry conformation.

Jas
12-09-2007, 12:24 AM
Ok, so now here is what's happening. The email "sends," but when I check my account, nothing is there.



<?php

function notify_user($email){

ini_set('smtp_port',25);
ini_set('SMTP','www.mysite.com');
ini_set('sendmail_from','admin@mysite.com');

$to = $email;

$subject = 'www.mysite.com Application';

$message = 'Your Application Was Accepted!';

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'From: Admin <admin@mysite.com>' . "\r\n";

// Mail it
echo mail($to, $subject, $message, $headers);

}

notify_user('me@hotmail.com');
?>

thetestingsite
12-09-2007, 12:33 AM
Question, why are you echoing the mail function?



echo mail($to, $subject, $message, $headers);

Jas
12-09-2007, 12:34 AM
To see if it sent. It is a test srcipt for now, so the resulting 1 or nothing doen't matter. (It prints 1 if it sent, nothing if it didn't.)
It is sending, or it says it is, but the message is not there when I check my email.

thetestingsite
12-09-2007, 12:44 AM
Well, the script itself works. You may want to check if you have the permission to use the mail server that you set in the ini_set functions at the top of the script. Other than that, you will want to make sure that the server does in fact have a mail server installed.

Hope this helps.

Jas
12-09-2007, 12:48 AM
I run the server on my comp (win XP and WAMP with your mailing program)

Twey
12-09-2007, 12:50 AM
You need to set an appropriate SMTP server and port in your config.

Jas
12-09-2007, 12:54 AM
How will that change anything? I am setting it with ini_set() for now, so that I can make changes until I get it right.
EDIT: if you mean something besides www.MySite.com, I am not really using that. I changed it for the post. . .
EDIT2: Hey! www.MySite.com really exists lol.

The message that I am trying to send shows up in hmailserver under the "undelivered messages" tab.

Twey
12-09-2007, 01:12 AM
What are the headers on the message?

Jas
12-11-2007, 03:45 AM
What? I'm not sure I understand the question. Are you refering to the $headers variable? That enables me to send an HTML email. An email with no headers does not work either.

Jas
12-11-2007, 04:06 AM
Alright, I am getting really confuised. I am not sure if this is even the function that I am looking for. Here is what I need:

A user submits an application via a form.
A webadmin accepts the application.
An email is sent by PHP to the user saying that the application was accepted.

Is this even the right function to use? Can PHP do it? I am sooooooo lost :mad::(:mad::(

thetestingsite
12-11-2007, 04:17 AM
Either way; if you are trying to send an email from a website/web app, you need to use a server side language in order for it to work properly or as it is intended (if that makes any sense).

Hope this helps.

Jas
12-11-2007, 04:31 AM
Either way; if you are trying to send an email from a website/web app, you need to use a erver side language in order for it to work properly or as it is intended (if that makes any sense).

Hope this helps.

Okay, so it's the right language. What do I do? The message shows up under the hmailserver's undelivered tab (no errors in the php page) and the to address is the sendmail_from address. . . I am so lost. Why would it be trying to send it to the sendmail_from address?

thetestingsite
12-11-2007, 04:41 AM
One thing you could try is getting rid of the ini_set() functions in the script. By default, the php.ini file has localhost at port 25 as the mail server/port. In other words, if you get rid of this, the script should default to the hmailserver install as the mail server. As I have said before, the script itself is functional; but (something I didn't mention is that) I did take out the ini_set calls at the top of the script in order to test on one of my servers.

Hope this helps.

Jas
12-11-2007, 04:46 AM
So, should I put everything in the ini_set functions into the actual ini file, or are you saying that there is more to it?

EDIT: I tried and I am getting the same error. The message is trying to be sent to the sendmail_from address. . . At least that what hmailserver says.

thetestingsite
12-11-2007, 04:51 AM
I'm saying that the default php.ini file should be sufficient enough for your script to work.

Jas
12-11-2007, 05:11 AM
Well for some reason it doesn't.

Warning: mail() [function.mail]: SMTP server response: 550 The address is not valid. in [FILE] on line 39

Twey
12-11-2007, 07:48 AM
What? I'm not sure I understand the question. Are you refering to the $headers variable?No, I mean the actual headers on the message when it reaches your mailserver. What are they?

Jas
12-11-2007, 06:33 PM
Twey: I don't mean to sound incompetent (as if I ever don't), but I still don't understand what your asking for. :( I am really new to the whole "mail" thing. Where should I look in order to find what your looking for?

BTW: I feel compelled to admit that this script is not mine, in case someone thought it was. This comes from the PHP manual.

EDIT:
Testingsite: Could you take me through all of your configurations for hmailserver? Supose I just installed php and hmailserver. Exactly what would I do to configure it like yours (per se; in other words, what did you do in the PHP.ini and hmailserver program)? I know it sounds dumb, but I am definately running into a configuration error-- I am 99.99% positive. (And when you send a message, where does it go?)

Twey
12-11-2007, 08:20 PM
I am really new to the whole "mail" thing. Where should I look in order to find what your looking for?I don't know because I don't know that mail server. Perhaps djr33 will have an idea.

thetestingsite
12-11-2007, 08:30 PM
It's been a while since I used the hmailserver, so I don't remember off the top of my head what you need to configure. Your best bet would be to look in their support forums or documentation.

Hope this helps.

Jas
12-13-2007, 11:36 PM
Okay, I got it working. But not I am more discouraged then ever. When I send an email to yahoo, nothing happens. I wondered why, and then I tried hotmail and got this:



Subject: Undeliverable: Your Application
X-hMailServer-LoopCount: 1

Your message did not reach some or all of the intended recipients.

Sent: Thu, 13 Dec 2007 17:25:53 -0600
Subject: Your Application

The following recipient(s) could not be reached:

me@something.com
Error Type: SMTP
Remote server (65.54.245.72) issued an error.
hMailServer sent: MAIL FROM:<admin@mysite.com>
Remote server replied: 550 DY-001 Mail rejected by Windows Live Hotmail for policy reasons. We generally do not accept email from dynamic IP's as they are not typically used to deliver unauthenticated SMTP e-mail to an Internet mail server. http://www.spamhaus.org maintains lists of dynamic and residential IP addresses. If you are not an email/network admin please contact your E-mail/Internet Service Provider for help. Email/network admins, please visit http://postmaster.live.com for email delivery information and support



hMailServer

(Good grief! It takes me forever to remove all of my personal info :rolleyes:. . . lol)

What can I do now? Is it because the server is offline ? Or am I now worse off then a toasted marshmellow?
Seriously, though, why am I getting that and what should I do?

Twey
12-13-2007, 11:54 PM
You're worse off than a toasted marshmallow :p

If you have another mail account (Yahoo for example) you can use that.

Jas
12-14-2007, 12:13 AM
If you have another mail account (Yahoo for example) you can use that.

It won't work on yahoo either.


When I send an email to yahoo, nothing happens


And besides, this has to send email to the user, not me, so it needs to work on as many email servers as possible.

What is causing this catastrophe and how do I fix it? :eek: I must be lacking something that other servers have.

thetestingsite
12-14-2007, 12:22 AM
I must be lacking something that other servers have.

- A static (external) IP Address
- An active/valid MX record
- &c

Jas
12-14-2007, 12:24 AM
- A static (external) IP Address
- An active/valid MX record
- &c
How does one aquire such marvelous things? (Tell me it's not my ISP or I'll. . . I'll . . . I don't know, but I won't be happy. :mad:)

Twey
12-14-2007, 12:29 AM
It won't work on yahoo either.Not sending to Yahoo -- using their SMTP servers to send your mail.
How does one aquire such marvelous things? (Tell me it's not my ISP or I'll. . . I'll . . . I don't know, but I won't be happy. :mad:)It's your ISP. The static IP, anyway; you can set up a domain and MX record yourself.

Jas
12-14-2007, 12:32 AM
Not sending to Yahoo -- using their SMTP servers to send your mail.
That sounds great, Twey. How do I do it and what are the chances of it working?

Twey
12-14-2007, 03:53 PM
Should work fine. Unless they've changed it, it sits on smtp.yahoo.com:25.

Jas
12-14-2007, 06:03 PM
Thanks Twey.

Should work fine. Unless they've changed it, it sits on smtp.yahoo.com:25.
Here are my settings:


ini_set('smtp_port',25);
ini_set('SMTP','smtp.yahoo.com');
ini_set('sendmail_from','me@yahoo.com');


It doesn't seem to work.


Warning: mail() [function.mail]: Failed to connect to mailserver at "smtp.yahoo.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in FILE on line 39

Twey
12-14-2007, 06:10 PM
Ah... they've changed it. Well, try another mailserver then, smtp.comcast.net:25 perhaps.

Jas
12-20-2007, 01:10 AM
Alright, so here is the deal: My goal was to get the site completely functional by 01/01/08, and this is the last thing on the check list :)

I was unable to get anything to work, so could someone provide me with a working setting for either yahoo or msn ? I would be very grateful for any more help I can get on this.

Or, if there is some kind of a fix for hosting the SMTP server myself (without changing my ISP), that would be great too.

BLiZZaRD
12-21-2007, 01:06 AM
Although I have never seen the changes make a difference myself, I have heard others say that changing from port 25 to port 2525 worked for them.

Jas
12-21-2007, 09:11 PM
I have an account to gmail that I am going to use, but in php I am getting this:


530 5.7.0 Must issue a STARTTLS command first v35sm3119040wah

I don't know what to do. How do I fix this in PHP? (all the gmail help is for outlook. . . )
Something about SSL or something ? *Sigh*

Twey
12-21-2007, 09:17 PM
Kind of, the server is complaining that you're not using (TLS) encryption.

Jas
12-21-2007, 09:20 PM
How do I do that?
EDIT:------------
Okay, it's the fsockopen() function, right? But how does that fit in to the rest of the code?

Twey
12-22-2007, 01:11 AM
It doesn't at all. I don't think the PHP mail() supports TLS. Usually one would just run sendmail on the host.

Jas
12-22-2007, 05:11 AM
Okay, how do I do that? I am getting so confuised and annoyed and frustrated!:confused:

thetestingsite
12-22-2007, 05:47 AM
Just a quick question. Are you using your local server to test before uploading to the live site? If so, why don't you just upload your web hosting server so that you can see for sure if it works. As said before, your code is fine and should work; but you need to have an actual mail server running for it to work perfectly.

Hope this helps.

Twey
12-22-2007, 06:00 AM
You can't, sendmail doesn't exist for Windows.

Jas
12-22-2007, 04:19 PM
Twey: Noooooooooooooooooooooooooo!!! :eek::eek::eek:

thetestingsite: There's the problem. I am going to be hosting the site myself (on a windows XP as far as I know-- but it may be linux). Does it make a difference if it's not actually a site yet when I am hosting it myself?

Speaking of, Twey, would it work on a linux?
Otherwise, what should I do now? I really need this function.

thetestingsite
12-22-2007, 05:18 PM
Well, if you are going to be hosting it yourself, you will need to make the machine a functional server. This usually means having a web "server" (apache), some server side languages (php, asp, perl, etc), database (mysql, postgresql, etc), and a mail server (hmailserver, iMailServer, sendmail, postfix, etc). I recommend running it on a linux machine as it is usually more reliable; however, I have run hosting machines with Win XP before and it worked fine. I recommend finding a host that already has the server set up for optimal performance and functionality.

Hope this helps.

Twey
12-22-2007, 05:47 PM
Speaking of, Twey, would it work on a linux?Yes.
I recommend running it on a linux machine as it is usually more reliableAlso one heck of a lot easier to set up. The basic LAMP environment can usually be installed and configured in a single command.

thetestingsite
12-22-2007, 07:01 PM
Yes.Also one heck of a lot easier to set up. The basic LAMP environment can usually be installed and configured in a single command.

I couldn't agree more.

Jas
12-22-2007, 10:21 PM
Hate to interupt the bash on microsoft :p but that's not what I am interested in. I need a fix to make this emailing function work. How do I do it, even if it isn't with gmail? (preferably on windows for now.) Nothing has been going right on this one. . .

But while we're on servers, what do I need (besides wamp) to turn either an XP or a linux into a server?
(emailing is still the priority here, though :))

thetestingsite
12-22-2007, 10:26 PM
as said before:



This usually means having a web "server" (apache), some server side languages (php, asp, perl, etc), database (mysql, postgresql, etc), and a mail server (hmailserver, iMailServer, sendmail, postfix, etc).


Hope this helps.

Twey
12-22-2007, 10:51 PM
Hate to interupt the bash on microsoftThat was an objective statement. It seems you are having quite a lot of trouble setting up a working webserver on Windows. I do too. There's a lot of effort required, which is why packages like WAMP exist, but you're still having issues. On Fedora, this would be:
yum install httpd php... and you're ready to start serving pages (complete with emails if necessary, everything includes sendmail). It's not necessarily a bad point of Windows, but Apache, PHP, and MySQL were all designed for UNIX-like platforms and are used most often on those platforms, and it's consequently a lot easier to work with them there.

Jas
12-22-2007, 10:53 PM
That's great, but in a nutshell you're saying that I need WAMP (which obviously has apache and PHP and MySQL) and a mail server. My question is: do I need anything else? And, I don't need a mailserver if I am using another site's SMTP, do I?

EDIT: thanks Twey.
EDIT2: So, if I did this on a UNIX, what would I need to change in my original script, and would I be able to host the SMTP myself, or would my ISP still mess it up? (if it messes it up, how do I use gmail?)

thetestingsite
12-22-2007, 11:16 PM
if you really want to host your own site, it is best that you get a working mail server installed on your system. Most servers (like gmail, yahoo, etc) require that you login first so that you do not send spam and/or viruses from their servers without having logged in (so that they can "track" your activity; which is why it is best to have some sort of mail transfer agent (mail server) on your hosting machine.

hope this helps.

Jas
12-23-2007, 04:08 AM
Okay, but how do I do that? I asume with hmailserver, but how do I configure it or. . . whatever I need to do. . .

EDIT: Sorry, I sound rude. When I get down to the wire I get like that. . . Two days left, then I go out of town, then I miss my deadline.

Jas
12-29-2007, 07:24 PM
Does anyone know how to do it? (You'll have to be a bit patient with me-- I don't really know anything about this. I am also out of town right now, so I apologize if I don't reply quickly.) I need some step by step instructions-- I've googled it many times, but there are only scripts which assume that you already have all of that figured out. :(

Jas
01-06-2008, 07:18 PM
Okay, I found this a while back, but I couldn't tell if it was of any use to me.
http://sourceforge.net/projects/gmail-lite/
Can this solve my problems? If so, how do you recomend I implement it?

tech_support
01-07-2008, 03:24 AM
I have an account to gmail that I am going to use, but in php I am getting this:



I don't know what to do. How do I fix this in PHP? (all the gmail help is for outlook. . . )
Something about SSL or something ? *Sigh*
Try this:
http://gmail-lite.sourceforge.net/wordpress/index.php/about/libgmailer/