Jump to content

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini! But it is!


Hepp

Recommended Posts

I have two different servers, a web and a mail server. The mail server uses localhost and the port of 25 for SMTP in php.ini, and the "sendmail_from" is set in php.ini - I'm 100% sure.

 

I tried making a simple mail script work...

 

<?php

// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
mail('BlahBlah@gmail.com', 'My Subject', $message);

?>

 

I have the php.ini "sendmail_from" setting to a different email than in that code. I need the code to have different emails for such things as a forgot password script when parsing info over $_POST, like the email. I need it to send the info to their email, not the one in php.ini.

 

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in *FilePath* on line *SomeNumber*

 

And it's given me a headache to the max. And now I'm angry at this thing. GAH!  >:( ???

 

Any suggestions?

 

Thanks for the help if so  ;D

Link to comment
Share on other sites

Hi,

1st of all u have to call or pass 4 arguments in ur mail function.

U forgot to define the From: argument or headers.

Do it like this:

$headers = 'From: My program <yourmail@domain.com>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

 

Then:

mail('BlahBlah@gmail.com', 'My Subject', $message,$headers);

 

Try this i think this will work.

 

 

 

Link to comment
Share on other sites

Progress... thank you for your reply mmarif4u.

 

I set the header email to the one in php.ini...

 

Now I only get this error message:

 

Warning: mail() [function.mail]: SMTP server response: 550 Account is not local, relaying disallowed.

 

Any more ideas? Anyone?

Link to comment
Share on other sites

Thank you for your help again.  ;D

 

I don't quite understand what your saying, but I need to use the email the user supplies in the input field in order for them to receive the mail and not the one in php.ini.

 

Like:

 

They enter their email, click "Retrieve Password", the PHP code matches their email with the one in the database and grabs their password, puts the correct password in the message, then sends the email to that users email, along with their password.

 

I need this.

 

Anymore suggestions?

Link to comment
Share on other sites

<?php

// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
mail('BlahBlah@gmail.com', 'My Subject', $message);

?>

 

Try this code:

<?php
//The headers
$headers = 'From: MY Program <webmaster@domain.com>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
// The message
$message = "Good Day!

Your personal password with username are as follows:

    email  : " . $cleaned_for_sql['email'] . "
    password: " . $password . "
    
Your New password for My program. 
Webmaster ";
// Send
mail($cleaned_for_sql['email'], 'My Subject', $message,$headers);
?>

 

But remember that have to run a sql query for matching the email and then retrieving the

password or username(what to u want to send to the user).

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.