Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: Bad Message Return Path (PHP)

Tags:

php

email

I'm new to php and I'm tying to set up a simple contact form script. I keep getting this message:

Warning: mail(): Bad Message Return Path in C:\xampp\htdocs\php_101\action.php on line 16

Here's my php code. Thanks:

ini_set('SMTP','smtpout.secureserver.net');
ini_set('smtp_port',80);
$name = $_POST['name'];
$to = "[email protected]";
$from = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
echo $subject, " from ", $name, " at ", $from, "<br/>";
echo $message;
$retval = mail( $to, $subject, $message );
like image 874
Binyamin Green Avatar asked Oct 29 '25 14:10

Binyamin Green


1 Answers

As per your comments, you're trying to use Gmail server to deliver messages to oblivy.com. Google will never allow that unless you're a registered and authenticated user. Servers that accept messages from anonymous parties for any destination are called open relays:

An open relay (sometimes called an insecure relay or a third-party relay) is an SMTP e-mail server that allows third-party relay of e-mail messages. By processing mail that is neither for nor from a local user, an open relay makes it possible for an unscrupulous sender to route large volumes of spam. In effect, the owner of the server -- who is typically unaware of the problem -- donates network and computer resources to the sender's purpose. In addition to the financial costs incurred when a spammer hijacks a server, an organization may also suffer system crashes, equipment damage, and loss of business.

They became a problem in the late 1990s and blacks lists of open relays were created, so mail server administrators could just reject any incoming mail from such servers.

Thus you need to create a Gmail account and provide its credentials when sending mail. Additionally, if you enable two-factor authentication you also need a dedicated application key to use here (instead of your regular password).

And to send email with authentication you need a full-fledged mail library that supports SMTP-AUTH (and possibly encryption). Good old mail() doesn't.

like image 104
Álvaro González Avatar answered Oct 31 '25 05:10

Álvaro González



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!