Pages

Showing posts with label mail function. Show all posts
Showing posts with label mail function. Show all posts

Friday, March 28, 2014

How to send mail from localhost/XAMPP with mail() function

You can send mail from localhost with sendmail package , sendmail package is inbuild in XAMPP. So if you are using XAMPP then you can easily send mail from localhost.
for example you can configure C:\xampp\php\php.ini and c:\xampp\sendmail\sendmail.inifor gmail to send mail.
in C:\xampp\php\php.ini find extension=php_openssl.dll and remove the semicolon from the beginning of that line to make SSL working for gmail for localhost.
in php.ini file find [mail function] and change
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
Now Open C:\xampp\sendmail\sendmail.ini. Replace all the existing code in sendmail.ini with following code
[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id@gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id@gmail.com
Now you have done!! create php file with mail function and send mail from localhost.
PS: don't forgot to replace my-gmail-id and my-gmail-password in above code. Also, don't forget to remove duplicate keys if you copied settings from above. For example comment following line if there is another sendmail_path : sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" in the php.ini file


Posted by honeyonsys

Saturday, April 13, 2013

How to send an html formatted mail with php mail() function



To send an html formatted text or emailer with php mail function you need to put correct syntax and header information inside you mail function. The most important is to have the header information. Because header will tell your function that your email contain what format of text, for that you can use



$headers =  'MIME-Version: 1.0' . "\r\n" .
                 'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
                'From:'.$email . "\r\n" .
                        'Reply-To: '. $email . "\r\n" .
                        'X-Mailer: PHP/' . phpversion();

for a better explanation the example is as follows



You should type this manually, thats how you will learn :)


posted by honeyonsys

About Me

Hi,My name is Harish Kumar.I am a web developer by profession.I am working in the same field since 2008. About my skills i am proficient in HTML,CSS,JAVASCRIPT/JQUERY/ ANGULAR,PHP,MYSQL,APACHE,LINUXAJAX, REST,etc...