One of our clients is using a webhost that blocks all emails sent from an unknown i.p. address....basically blocking any email forms being used on their server. The hosts have said for emails to be sent via their server the form needs to act as if the email was sent from the SERVER ip address and not the remote address.

Anyone know any ways to do this

Dani AI

Generated

Short answer: changing a PHP variable or the message From: header will not hide the IP that mail transfer agents record. is right to look up the server IP, but SMTP servers insert their own Received lines that show the TCP client IP (so the mail still reveals where the connection came from) RFC 5321.

Practical fixes that work today: send the messages through the webhost's authenticated SMTP relay or a transactional-mail API instead of relying on unauthenticated delivery from the web script. Authenticated SMTP ensures the connecting client is the host/relay they trust, which satisfies IP-based filters. Use a mail library that supports SMTP auth (for example see the PHPMailer SMTP guide) so credentials, TLS and envelope parameters are handled correctly PHPMailer Using SMTP.

Notes and troubleshooting:

  • Ask the host exactly which header or field they are checking (Received, X-Originating-IP, Return-Path, etc.). Some providers add extra headers; knowing which one they check makes the fix explicit.
  • mail() can set the envelope sender (Return-Path) via the sendmail -f parameter, but that does not remove Recorded/Received entries added by MTAs — it only sets the envelope address (see the PHP manual) PHP mail() manual.
  • If the form must send on behalf of another domain, update SPF/DKIM to authorize the relay; otherwise messages may be rejected or marked spam RFC 7208.

If the host will not provide an authenticated relay or whitelist, request their recommended relay/API or consider using a reputable transactional provider so form mail is reliably delivered.

Not sure if I completely understand your problem, but have you looked at

$_SERVER['SERVER_ADDR']

which holds "The IP address of the server under which the current script is executing. "

i know about that but that doesn't change the details in the header, it will still show as the remote address

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.