Jump to content

Php Mail Function Not Working


toreachdeepak
 Share

Recommended Posts

Hi,The php mail function is not working on linux.Please help in understanding which settings are required.I have done following settings on my linux machine; For Unix only. You may supply arguments as well (default: "sendmail -t -i").sendmail_path = /usr/sbin/sendmail -tsendmail_from = myemail_addressThanksDeepak

Edited by DeepakBhatia
Link to comment
Share on other sites

Are you getting any warning or error messages? Is mail() returning true or false? Are you certain the code is even parsing correctly?
Hi,For the code below, the web page waits for a minute or so and then prints "Mail Sent". The mail returns true means ut has worked.<?php$Name = "Da Duder"; //senders name$email = "deepak.bhatia@nechclst.in"; //senders e-mail adress$recipient = "deepak.bhatia@nechclst.in"; //recipient$mail_body = "The text for the mail..."; //mail body$subject = "Subject for reviever"; //subject$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfieldsmail($recipient, $subject, $mail_body, $header); //mail command :)?><h1>Mail Sent</h1> Edited by DeepakBhatia
Link to comment
Share on other sites

How can you tell the mail() function returns true? Check it:

if (mail($recipient, $subject, $mail_body, $header)) echo "Mail sent.";else echo "Mail not sent.";

Also, if everything seems to work check your spam folder.

Link to comment
Share on other sites

SSL is not the issue. You should be checking the return value of the mail function, the code you posted doesn't tell you if it succeeded or not, you always print the same message no matter what happens. If there's a delay in sending the mail it probably can't connect to the mail server. Make sure errors are being reported also:error_reporting(E_ALL);ini_set('html_errors', 1);ini_set('display_errors', 1);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...