Jump to content
Larry Ullman's Book Forums

Php "Mail" Function Not Working On Host Server


Recommended Posts

The following mail function works fine from my own localhost server but I get no mail when I upload it to my host.

Thoughts??

 

mail($row['e'], $subject, $body, 'FROM: Gill@maaa.net');

echo "<p>mailed to: ".$row['fn']." ".$row['ln']."</p>";

Link to comment
Share on other sites

I don't get an error. I simply don't receive the email. Same script on my local server works okay. The response that I do get from the script indicates that it reaches the line: "mail($row['e'], $subject, $body, 'FROM: Gill@maaa.net');"

 

Does something need to be set in the .ini file on the remote server?

Link to comment
Share on other sites

Three likely causes:

1. $row['e'] doesn’t have a valid value

2. The FROM email address is inappropriate for that domain.

3. The email is being sent but eaten by the client's spam filter.

 

It's unlikely that a mail server isn't configured on your host.

Link to comment
Share on other sites

I tried 3 different emails for $row['e']. It only worked with one of them which happened to be the only one that is associated with the hosting account on which the script resides. The other two email addresses have nothing to do with that hosting service. Is this the problem? I can only send mail to my own addresses associated with my account? Seems like it!

 

I wanted to be able to send out a short email blast to inform "members" in my database whom have not paid dues, that their account is overdue. Perhaps I need to run such a script from my own localhost computer?

Link to comment
Share on other sites

I talked to tech support at my hosting site. Their spam filter gobbled it up because, according to them, I am actually sending two "FROM" header fields when I send:

"mail($row['e'], $subject, $body, 'FROM: Gill@maaa.net');"

 

Apparently the FROM field shouldn't be included because the host fills in its own FROM automatically. Problem is, I don't want THEIR from, I want my own. So, it does work without the last argument in there but I've reopened the ticket to see if there is a way to substitute my own FROM. I'll post my findings later.

Link to comment
Share on other sites

The final resolve. Sent from tech support:

------------------

All emails sent from this account using the mail() function will be issued from the cPanel mailbox

 

negland@serv01.siteground117.com

 

In order to be able to send the emails from another mailbox, like noreply@portfolioNE.com, or info@portfolioNE.com, you need to code the script to connect to the mailbox you prefer via SMTP and then send the emails.

 

For the purpose you might need the assistance of a professional developer. In case you don't have a developer to work with, you might want to check the popular freelance websites.

 

------------

Any help is appreciated. Meanwhile, I'll research such a script and post it if successful.

thanks

Link to comment
Share on other sites

This probably won't help, but this isn't very good hosting. It's great that they answered your question, but sending emails from that address and not letting you change this using the FROM header is new to me.

 

You can't use PHP's mail() function to directly connect to an SMTP server. You'll need to use a third-party library, such as the Zend Framework component, to do this.

Link to comment
Share on other sites

Yes, it's odd. But I'll have to go with the unfriendly looking text in the "From:" for now and just hope to catch their attention in the "Subject:" slot before they trash the email.

 

Thank you for your responses. I'll survive.

Link to comment
Share on other sites

 Share

×
×
  • Create New...