Filed under: LAMP | Tags: mail from localhost, php.ini mail config, send mail, send mail from localhost
Many developer today like to test php mail script from localhost. Dislike to upload script in server for test. Moreover, like to finalize everything from localhost/own development platform. Furthermore need to configure your php.ini file what send mail using local SMTP.
A number of php.ini files are there in PHP, MySql and Apache. Which one you have to configure? Definitely not everyone. Mail as well as SMTP are very closely and intimately related with apache (web server). So you have to configure php.ini under apache\bin\php.ini. Just follow the following instructions: Change the configuration of apache\bin\php.ini file accordingly:
Default: ;
SMTP = localhost
Change it To : SMTP = “mail.gmail.com”
Effects/Reason for Change: Give outgoing mail address
Default: ;
sendmail_from = me@example.com
Change it To : sendmail_from = aminulsumon@gmail.com
Effects/Reason for Change: Default mail address where from mails are being sent
Default: max_execution_time = 30
Change it To : max_execution_time = 90
Effects/Reason for Change: Sometimes this execution takes time more then 30 sec.
Don’t forget to remove the beginning semicolon (;) each line which you have changed. Semicolon means comments here.
Now use mail() function to send an Email from localhost.
Test Script:-
$MailTo=”aminulsumon@gmail.com”;
$MailFrom=”Sender Aminul”;
$MailFromEMail=”info@gmail.com”;
$Subject=”Test mail from Localhost”;
$MailBody=”Message: Testing Mail from Localhost You can write here .”;
$Headers = ‘MIME-Version: 1.0′ . “\r\n”;
$Headers .= ‘Content-type: text/html; charset=iso-8859-1′ . “\r\n”;
$Headers .= “From:”.$MailFrom.”\r\n”;
if(mail($MailTo,$Subject,$MailBody,$Headers))
echo “Mail sent Successfully.”;
else
die(“Sorry! The mail not sent successfully.”);
Hope you are able to send email from your local pc by the help of internet connection
No Comments Yet so far
Leave a comment
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>