MAIL() oddity

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Silver_Girl
Forum Newbie
Posts: 7
Joined: Wed Mar 02, 2005 4:52 pm
Location: Victoria, BC

MAIL() oddity

Post by Silver_Girl »

I seem to have developed a mail function that will only send to email address' where my ISP is running the DNS for that domain.

Essentially, it will send to me and all my co-workers, but not to any other email address'

here is my code:

Code: Select all

<?php

// message
$message = '
 
Dear whomever,' . "\r\n\r\n" .

'this is my letter' . "\r\n\r\n" .

'Thank you,' . "\r\n\r\n"  . $_POST&#1111;'name'] . "\r\n" . $_POST&#1111;'city'] . ", " . $_POST&#1111;'province'] . "\r\n" . $_POST&#1111;'email'];

// headers
$headers  = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Email <email@email.com>' . "\r\n";
$headers .= 'From:"' . $_POST&#1111;'name'] .  '"<' . $_POST&#1111;'email'] .  ">" . "\r\n";

// Mail it
mail('email@email.com', 'subject', $message, $headers);
?>

The TO: email will be hard coded when it is finished, but it will not to some who's email hosted at our ISP.

My first thought is that this may be a problem with our IPS's sendmail. I have received everything when i send it to my email that they host. and then the email is received perfectly, headers in tact. but i receive nothing when i am sending my other email address', including hotmail, gmail and my person domain.

i'm wondering if anyone has experienced this same problem, and if so, how did you solve it?
User avatar
Silver_Girl
Forum Newbie
Posts: 7
Joined: Wed Mar 02, 2005 4:52 pm
Location: Victoria, BC

Post by Silver_Girl »

No one has any thoughts on this eh?

is it possible that my ISPs mailserver is stopping anything it doesn't recognize from being posted?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Yes but it is more possible you haven't configured your SMTP settings in php.ini correctly :wink:
User avatar
Silver_Girl
Forum Newbie
Posts: 7
Joined: Wed Mar 02, 2005 4:52 pm
Location: Victoria, BC

Post by Silver_Girl »

haha, thanx


unfortunately i do not have access to the php.ini. I can email my isp, but they have not been very helpful in the past unless i have been very specific about the problem.

do you know have any suggestions about what the problem with SMTP settings in the php.ini might be?

and no, changing ISPs in not an option :wink:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Well... if you know what the smtp should be then you can put the settings in your code without using the ini file.
ini_set('SMTP', 'your.smtpserver.com');
ini_set('sendmail_from', 'youremail@yourdomain.com');
It may not even be the same problem.. to be honest I haven't even looked at your code but it would be the weirdest problem if you'd managed to code it to do that by accident.

EDIT: Many people say that they dont have access the php.ini but in most (not all) cases you can set the ini for the duration of the script using ini_set()
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Well looking at your code there's nothing in there that restricts who you send it to....
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

Silver_Girl - I like the blog. I tried to figure what number I was but then I hit #3 and thought they all fit me lol.
Sometimes you can be manipulative
You're a bit narcissistic
Being too much of a perfectionist
You've got a masochistic streak
You tend to be a bit passive sometimes
You tend to be excessive with things you enjoy
You are too aggressive at times
People think you're quite weird
You tend to get depressed easily
Seriously though. You get no errors or warnings? Bounced mails? Is there a problem with mail forwarding? Try out a class like phpmailer and see if it works properly.
User avatar
Silver_Girl
Forum Newbie
Posts: 7
Joined: Wed Mar 02, 2005 4:52 pm
Location: Victoria, BC

Post by Silver_Girl »

this sounds great, thank you,

of curse, now i run into that my ISP (hosting) has not actually provided us with an outgoing mail server. We are using our ISP's (internet access) outgoing mail server,

i did ask if this was going to be an issue using PHP mail(), i was assured because they have set up an outgoing server with /usr/sbin/sendmail

and i making any sense? i know little about mail servers and servers in general
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

It makes sense. I have seen some mail servers set so tight that they really limit mail forward. They might let mail go to a user on the same domain but not external domains.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Not 100% what you're trying to say but as far as using smtp on another ISP's server it's pretty much impossible due to mail relaying legalities today.

Basically you can't use somebody elses smtp server... you must use the one assigned to your ISP (maybe it's different if it requires authentication - i'm not sure).
User avatar
Silver_Girl
Forum Newbie
Posts: 7
Joined: Wed Mar 02, 2005 4:52 pm
Location: Victoria, BC

Post by Silver_Girl »

just that i am discussing two different types of ISP, the one that is hosting the site that i am working on and the one that provides our internet access.

the one we are hosting with, does not provide an outgoing mail server, even though our domain is hosted through them and they are controlling our incoming mail.

the other thing i should mention is, that when i upload this to another server, it works fine, it's a pretty basic mail code.

thanx for reading the blog, that's why it's there, and yes, i am getting no errors, bounce backs or anything.

i tried the ini_set(), i also looked at some on it's other permitters, but still, i get nothing
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

So the ISP that controls your internet access has the SMTP server and they claim you should be able to send mail? I am trying to picture this in my head...

So you are using one ISP to surf the net and you are using them to send your email. But then you have another ISP that hosts your web pages and you have it try to send your email through the other ISP. If that is correct, let me ask these questions. If you have already answered, I apologize. I want to see the answers in one spot so I can see if I can help.

1. Can you send email from your computer through the hosting ISP with no problems?

2. Assuming that: Can you go home and use a computer there and send an email through your internet providing ISP?

3. If number 2 is a yes, did you have to tell that ISP your IP address so you could send email?

4. If number 1 is a yes, do you know if that ISP has registered your web serving ISP's IP address to its mail server?

I ask because sendmail and others can be set to allow relaying. If relaying is set, they may require the IP address of trusted computers that can send email.

If that is the case, your mail serving ISP may have to enter the web server ISP's IP address in their mail relaying file so it would be seen as a trusted source for sending email.

If any of this is confusing, please ask and I will try to clarify.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Sounds good to me... just depends on how cooperative her internet providing ISP is going to be :? Seems strange that your web host doesn't have smtp set up... (Were you not given an email account with your hosting plan?)
User avatar
Silver_Girl
Forum Newbie
Posts: 7
Joined: Wed Mar 02, 2005 4:52 pm
Location: Victoria, BC

Post by Silver_Girl »

uhm yah

our host is kinna a joke, but a friend of the owner of the company :roll:

i'll have to give them a call on this, thanx for all your help
Post Reply