Sending mail with mail() without header

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm working on a website where there is a from from which I want to
send the data by e-mail.

When I send myself the result with mail($my_email, $title, $message)
everything works fine and I receive a plain text email. However, the
people for which I'm doing the site receive some kind of error when I
do the same thing but delivered to them > mail($their_email, $title,

The error looks something like this:

Your message cannot be delivered to the following recipients:

  Recipient address:
  Reason: Illegal host/domain name found

I also used something like this in the script to make it work when
sending it to myself:

    ini_set('SMTP', '');
    ini_set('sendmail_from', '');

Is it the fact that I send this email in plain text with no headers
that could trigger some sort of spam filtering?

If so, what headers should I be using?

Thanks in advance

Re: Sending mail with mail() without header

Quoted text here. Click to load it

I can't give a lot of detail, but it's because the Headers are non-RFC
compliant, I imagine.  Without the envelope "from" and "return path"
etc. many ISPs will reject the mail.  I imagine someone who can give you
specific details will be along shortly.


Re: Sending mail with mail() without header

Thanks for this piece of info.

It helps to know where the problem comes from.

Quoted text here. Click to load it

Re: Sending mail with mail() without header

Quoted text here. Click to load it

Well, since no one else has come along yet I'll give you what little I
know from my meager experience:
You have to have From.  Not the From that prints for the recipient, but
the From header in the envelope.
  I think the Return Path is derived from that.

You need to identify the content type.  e.g. texp/plain, etc.

Then the doctype, and etc. etc..  PHPNet and W3 schools both have good
articles on them; I'd do some checking there to get going if this is new
to you. Basically you have a set of requireds and then a set of "if you
wanna" types of headers.

 I'm new at this too so getting too specific would be the blind leading
the blind <g>.



Re: Sending mail with mail() without header

You don't have to set headers if you ini is set properly, even though
I've never had to set anything in my ini for my mail scripts. I do now
however format the headers properly... excerpt from ini

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from =

; For Unix only.  You may supply arguments as well (default: "sendmail
-t -i").
;sendmail_path =

What are they using for mail? What OS is php running from? If it's
winders check to see if they have the smtp relay open, if not (more
than likely) have the admin add the server to allow it to relay, I
don't remember where it's at off the top of my head as my server admin
hat has a bit of dust one it.

When using headers use similar to this format $header .= "From:
$webmaster" . "\r\n"; . The last part is important, Google for more

Re: Sending mail with mail() without header

The Hajj wrote:
Quoted text here. Click to load it

No, you don't HAVE to set headers to send the email.  But if you don't
have certain headers, some spam filters will chuck the message.

An example is not having Reply To: - if it's missing or doesn't match
the From: header, it won't make it through some spam filters.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline