Forum Moderators: coopster

Message Too Old, No Replies

php mail() will show "from" as any domain i want.

except my own!

         

notionphil

4:00 pm on Jul 8, 2008 (gmt 0)

10+ Year Member



I'm using the php mail() function to send an automated email to an email address on file when a visitor performs a certain action. Everything is working fine except that the "from" of the email won't display what i'd like it to "My Site <accounts@mysite.com>"(assuming my domain is mysite.com). Instead it writes some server name such as box81@hostingcompany.com.

The bizzare part of this problem is that if i change the "from" in the header to anything OTHER than my actual domain such as "Gobbledegook <MrHappyTime@ThisDoesntExist.erhjw>" it actually works and sends the mail out with the "from" header as requested.

Here's my code:

$headers = 'From: My Site <accounts@mysite.com>' . "\r\n";
$sendTo = "$email";
$subject = "Welcome to My Site!";
$headers .= "Reply-To: accounts@mysite.com\r\n";
$headers .= "Return-Path: accounts@mysite.com";
$headers .="-faccounts@mysite.com";
$message = "Welcome to My Site! \n\nBla Blah Blah";
mail($sendTo, $subject, $message, $headers);

I've tried it with or without the -faccounts@mysite.com line, doesnt seem to matter. I also attempted to find the etc/mail/trusted-users file as some told me that was the solution. I know nothing about file systems or servers, i'm more of a designer and coder, so this was really confusing to me. i tried to create a new etc/mail/trusted-users file but that didn't solve the problem.

Any insight here? And why would it let me create any OTHER domain besides my own?

eelixduppy

5:56 pm on Jul 8, 2008 (gmt 0)



Welcome to WebmasterWorld!

This doesn't make any sense to me. If you have a hosting company I would contact their technical support if they have it.

notionphil

6:03 pm on Jul 8, 2008 (gmt 0)

10+ Year Member



doesn't make much sense to me either. however i fixed the problem...i created an email account with the same name and domain as what i wanted to send from, and now it works.

That makes plenty of sense that an account in the same name would be required....what doesnt make sense is that i could use any other domain besides my own, with addresses that weren't even valid domains in the From header...

oh well. problem (strangely) solved.

thanks!

Phil

eelixduppy

6:12 pm on Jul 8, 2008 (gmt 0)



Cool. Glad you figured it out :) Seems like your host is trying to limit you however doing so incorrectly? Not sure. But most shared hosts do do this sort of this to prevent spam from being sent from their servers. Oh well