Sendmail issue: successfully sent but never arrives
Solution 1
Are you sure the recipient SMTP server isn't dropping (or at least greylisting) your mail? It's very common for mail servers to treat messages not coming from a recognized MX server as being spammy.
Is sendmail configured to use an SMTP relay/smarthost? If not, what happens if you configure it to use your ISP's, employer's, or other hosting provider's server?
Solution 2
have you set up the configuration in your php.ini file?
When i setup php on my own server (I was running IIS on server 2003, with Exchange for emails), I had to edit the php.ini file to configure the Mail function.
Just had to uncomment andspecify my mail server for the SMTP
part.
Edit
[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = #mymailserver# ; http://php.net/smtp-port smtp_port = 25
You will probably have to do the same, or similar, depending on your web server environment
Andreas Hagen
Updated on June 09, 2022Comments
-
Andreas Hagen almost 2 years
I'm trying to send mail via the PHP mail() function which as far as I have understood uses sendmail to deliver the goods. Now my problem is that mail() returns true but there is not even a trace of the mail in my mailbox (yea i checked spam too).
So i tried to send some mail manually from the terminal but the problem persists. sendmail does not give me an error, except from a unable to determine domain error which i fixed by adding the domain for my dev-machine to /etc/hosts and related it to 127.0.0.1.
andreas@Andreas-PC-Ubuntu:~$ sendmail [email protected] Test . andreas@Andreas-PC-Ubuntu:~$
As well as giving no error, sendmail logs that the mail was sent successfully in /var/log/mail.log:
Apr 7 01:16:21 Andreas-PC-Ubuntu sendmail[11759]: q36NGIfD011759: from=andreas, size=5, class=0, nrcpts=1, msgid=<[email protected]>, relay=andreas@localhost Apr 7 01:16:21 Andreas-PC-Ubuntu sm-mta[11760]: q36NGL1J011760: from=<[email protected]>, size=299, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=ip6-localhost [127.0.0.1] Apr 7 01:16:21 Andreas-PC-Ubuntu sendmail[11759]: q36NGIfD011759: [email protected], ctladdr=andreas (1000/1000), delay=00:00:03, xdelay=00:00:00, mailer=relay, pri=30005, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q36NGL1J011760 Message accepted for delivery)
So yea, any suggestions?
-
Andreas Hagen about 12 yearsNo, the php.ini sendmail config is just the default, but i supply the from address myself via $additional_headers and sendmail binary is located where default php.ini will try to look for it. Moreover the error I'm most interested in solving here seams to be with sendmail itself not PHP, as i described it does not send mail.
-
Andreas Hagen about 12 yearsThat is probably part of the issue yes, I'm using standard config for sendmail which was installed along from the Ubuntu repositories. How do I do this? On a sidenote, if the recipient server drops it due to bad MX setup, how is it that from my primary hosting server (I didn't set up sendmail on this so no clue how it works) I am able to supply whatever from address I'd like and everything is delivered fine? I'm sorry if some of this is kind of obvious, but this is my first time working with mail :)
-
OACDesigns about 12 yearsI take it this is your server?
-
Andreas Hagen about 12 yearsYes, as i said in the question it is my development machine actually.
-
Conrad Shultz about 12 yearsYour hosting provider probably setup mail relaying for you, akin to you entering an "outgoing mail server" when setting up a mail client on your desktop or smartphone. Do you know if Ubuntu is using exim as its sendmail implementation?
-
OACDesigns about 12 yearsoh sorry, didn't see that part. i've edited my answer, however my experience was with server 2003 running exchange for emails. You may need to edit a different part of the php.ini file as you're on linux (Ubuntu i assume from your quesition)
-
Andreas Hagen about 12 yearsNo, I'm sorry I do not know. Is there a parameter i can supply to sendmail to make it print that information or something?
-
Conrad Shultz about 12 yearsWhat do you get from
dpkg -l | grep exim
? (Btw, this is rapidly evolving into a question better suited to the Linux StackExchange or ServerFault.) -
Andreas Hagen about 12 yearsYes, if I'm not mistaken its the config directives sendmail_path and sendmail_from i need to configure. As described in the first comment i believe that they are not the problem since mail() returns true indicating a success in the binding between PHP and sendmail. Moreover the same issue persists without the PHP layer, when I use sendmail directly from the terminal, leading me to suspect some error with sendmail.
-
Andreas Hagen about 12 yearsYe I see it does. As for
dpkg -l | grep exim
, it gives me nothing. -
OACDesigns about 12 yearsah ok, got ya. Sorry I can't help you with this one. Sendmail configuration is out of my area.
-
Conrad Shultz about 12 yearsWell, I suggest searching google or the aforementioned sites for info in configuring mail relaying in Ubuntu. Sorry I'm not of more help, but I think this is the underlying problem.