PHP - mail not sending - No errors visible

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
jxfish2
Forum Newbie
Posts: 2
Joined: Thu Jan 30, 2014 8:17 am

PHP - mail not sending - No errors visible

Post by jxfish2 »

I could really use some help with this.

I have been coding in PHP for about 3 months now, and I've managed to put together some pretty fancy data driven web pages.

In my current work environment, I have never generated any mail messages via PHP.

I have been using Korn Shell and "mailx" for many years.

I have a need to generated email messages inside of my php code.

But, the environment that I'm in requires a mail aliasing entry for each message that I send.

Using "mailx", I would send a simple mail message using the following syntax:

cat $FILE | mailx -s"$(echo -e "PHP Test Message\nContent-Type: text/html")" "$DISTRO" -- -f SomeAddress@gmail.com

-OR-

echo "Something" | mailx -s"$(echo -e "PHP Test Message\nContent-Type: text/html")" "$DISTRO" -- -f SomeAddress@gmail.com

I never needed to add the "-- -f SomeAddress@gmail.com" until coming to this particular company.

But, if I do NOT add this snippet to the end of my mailx command, the messages will never leave the server.

I have been testing several different PHP mail entries, and I am NOT getting any errors, but the messages are just not being generated, or at least they are not leaving the server.

I am assuming that the issue is with this same exact snippet that I need to end my mailx commands with.

Can anyone tell me, or give me a sample mail command, that would include the above "-- -f SomeAddress@gmail.com" snippet?

Thanks in advance, and have a great day.

JCF
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP - mail not sending - No errors visible

Post by Celauran »

Take a look at mail() in the PHP manual.

Code: Select all

mail('nobody@example.com', 'the subject', 'the message', null, '-fwebmaster@example.com');
jxfish2
Forum Newbie
Posts: 2
Joined: Thu Jan 30, 2014 8:17 am

Re: PHP - mail not sending - No errors visible

Post by jxfish2 »

I tried the above, in each of the following formats:

'-femail@someisp.com'

'-f email@someisp.com'

'-- -femail@someisp.com'

'-- -f email@someisp.com'

I'm not getting any errors anywhere that I can see.

Is there some way to generate a logfile entry, or some type of flat file entry, that would show me exactly what values, what data, is being populated, or seen by the mail handler?

Is there some PHP logging function, that would allow me to log everything that this command is generating?

I already tried setting the default logging levels to their maximum, but no errors or logfile entries are being generated:

error_reporting(E_ALL);

TIA

JCF
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP - mail not sending - No errors visible

Post by Christopher »

What is the "-f" for? Just try 'webmaster@example.com'
(#10850)
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP - mail not sending - No errors visible

Post by Celauran »

You could also try setting the From: header manually
Post Reply