Page 1 of 1

mail() problem

Posted: Sat Oct 26, 2002 1:04 am
by nid
Like many I seem to be having problems with mail().

If I try to send a simple message, it works, but it arrives from "root@myserver.myhost.com".

I tried to get around this by plugging in the userid and SMTP settings I use for my email account:

ini_set("sendmail_from","user@mywebsite.com");
ini_set("SMTP","myserver.myhost.com");
phpinfo(); // looks ok
mail("sometest@hotmail.com", "My Subject", "Line 1\nLine 2\nLine 3");


BUT this doesn't work.

Also, one thing I don't get about this is what about the password? When I set up an email account in my email software, I need to supply a userid and password. mail() doesn't seem to allow for this, but everyone (except me) seems to be using it successfully. Can someone fill me in on how this works?

Thanks.

mail with the from

Posted: Sat Oct 26, 2002 2:08 am
by phpScott
I don't quite know how this will fit in with your code but this should help solve that from problem.

Code: Select all

<?php

mail ("you@here", "$subject", "$message", "From: <$sender>\n". "Reply-To: <$sender>\n");

?>
phpScott

Posted: Sat Oct 26, 2002 8:16 am
by nid
ok, thanks, that seems to work, but...

if you do this and examine the email (properties/details/message source in Outlook Express), it's still coming from "root@myserver.myhost.com".

I'm thinking of putting together a mass-mailing application (no spam!), and I'm not sure if it's ok to have my host's root id associated with the message... ?

I don't know

Posted: Sat Oct 26, 2002 1:50 pm
by phpScott
I have never encountered that problem before.
I use a very simillar script and when I looked at the header info in outlook I couldn't see anythin like that. :?
I will do some searching and see what I come up with.
go to http://www.php.net and do a search for mail.
It will come up with all sorts of info for you.

phpScott

Posted: Sat Oct 26, 2002 2:43 pm
by Takuma
I use this script and guess what it works! So it should wor on yours too.

Code: Select all

<?php
mail("your_email_address","subject","message","From: Hi");
?>
Then in Outlook it should say "From: Hi".