Jump to content

Custom php.ini file?


Losty

Recommended Posts

Alright so here's the dealio.

 

I created a basic feedback form with PHP. Did it, but received the following error:

 

Warning: mail() [function.mail]: SMTP server response: 553 sorry, that domain isn't allowed to be relayed thru this MTA (#5.7.1) in [file] on line 116

 

I looked into this and it seems that I need to config “SMTP” in the php.ini file.

 

The Problem: After calling the php info, I'm pretty sure it's my webhost that has access to this file. I contacted them, and they replied by telling me to create a custom one, as they are a "Microsoft Windows 2003 Server that specialize in ASP, ASP.NET, and SQL Server. We have limited experience with PHP."

 

So after swearing and cursing them out, I did some more snooping around to figure out how to create my own, and edit the SMTP settings.

 

Could I create my own php.ini file from this template: http://cvs.php.net/viewvc.cgi/php-src/php.ini-dist?view=co

 

And then add:

 

[mail function]

; For Win32 only.

SMTP = mail.host.com ; for Win32 only

smtp_port = 25

sendmail_from= [email protected] ; for Win32 only

 

; For Win32 only.

;sendmail_from = [email protected]

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

;sendmail_path =

 

; Force the addition of the specified parameters to be passed as extra parameters

; to the sendmail binary. These parameters will always replace the value of

; the 5th parameter to mail(), even in safe mode.

;mail.force_extra_parameters =

 

 

And if I can use that:

 

1. Where would I upload this file?

2. Would I run into issues with the php.ini file the site is already pointing to?

 

ANY help would be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/158767-custom-phpini-file/
Share on other sites

It's likely that you are putting the email address that was entered in the form into the From: header. The From: email address must be an email address hosted on the sending mail server. You should put any email address that was entered in the form into the Reply-to: header.

Link to comment
https://forums.phpfreaks.com/topic/158767-custom-phpini-file/#findComment-837367
Share on other sites

I'm a bit of a newbie at PHP coding.

 

This is the code I'm using:

 

<?php

if (isset($_REQUEST['email']))

//if "email" is filled out, send email

  {

  //send email

  $email = $_REQUEST['email'] ;

  $subject = $_REQUEST['subject'] ;

  $message = $_REQUEST['message'] ;

  mail( "[email protected]", "Subject: $subject",

  $message, "From: $email" );

  echo "<h2>Thank you for sending us Feedback. We will reply within 2 business days.</h2>";

  }

else

//if "email" is not filled out, display the form

  {

  echo "<h2>Can't send email to $email . Please hit the back button in your browser and try again.</h4>";

  }

?>

 

 

 

Have I made a mistake somewhere?

Link to comment
https://forums.phpfreaks.com/topic/158767-custom-phpini-file/#findComment-837394
Share on other sites

PFMaBiSmAd spelled it out for you: the "From: $email" is probably being blocked by the mail server because it doesn't allow relaying. Use "Reply-to: $email" instead.

 

Also, I'd validate that the provided email address is a real email address and doesn't include an exploit that hackers can use to send spam.

 

<?php
$emailFilter="/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i";
if(preg_match($emailFilter,$email) mail( "[email protected]", "Subject: $subject", $message, "Reply-to: $email");
else echo "error with email address."
?>

Link to comment
https://forums.phpfreaks.com/topic/158767-custom-phpini-file/#findComment-837840
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.