Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send email from local wamp server using PHP?

Tags:

php

email

wamp

I need to send email messages from my localhost.

I am using wamp server and my site is loaded on my own server, please could you suggest how to send emails using my localhost and PHP?

like image 699
Prasoon Avatar asked Oct 19 '11 10:10

Prasoon


People also ask

Can I send email from localhost PHP?

Send Email from Localhost with PHPSet SMTP credentials (host, username, password, and port). Specify sender name and email ( $mail->setFrom ). Set recipient email address ( $mail->addAddress ). Set email subject ( $mail->Subject ).

Can I send email using localhost?

If you want to send emails from localhost directly, you need to install a Mail Transport Agent (MTA), or if you like, a SMTP service. IIS provides one. You can otherwise find some others on Google.

How can you send email in PHP?

PHP makes use of mail() function to send an email. This function requires three mandatory arguments that specify the recipient's email address, the subject of the the message and the actual message additionally there are other two optional parameters. mail( to, subject, message, headers, parameters );


2 Answers

Here's the steps to achieve this:

  • Download the sendmail.zip through this link

    • Now, extract the folder and put it to C:/wamp/. Make sure that these four files are present: sendmail.exe, libeay32.dll, ssleay32.ddl and sendmail.ini.
    • Open sendmail.ini and set the configuration as follows:

    • smtp_server=smtp.gmail.com

    • smtp_port=465
    • smtp_ssl=ssl
    • default_domain=localhost
    • error_logfile=error.log
    • debug_logfile=debug.log
    • auth_username=[your_gmail_account_username]@gmail.com
    • auth_password=[your_gmail_account_password]
    • pop3_server=
    • pop3_username=
    • pop3_password=
    • force_sender=
    • force_recipient=
    • hostname=localhost

    • Access your email account. Click the Gear Tool > Settings > Forwarding and POP/IMAP > IMAP access. Click "Enable IMAP", then save your changes.

    • Run your WAMP Server. Enable ssl_module under Apache Module.

    • Next, enable php_openssl and php_sockets under PHP.

    • Open php.ini and configure it as the codes below. Basically, you just have to set the sendmail_path.

[mail function] ; For Win32 only. ; http://php.net/smtp ;SMTP = ; http://php.net/smtp-port ;smtp_port = 25  ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = [email protected] ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = "C:\wamp\sendmail\sendmail.exe -t -i" 
  • Restart Wamp Server

I hope this will work for you..

like image 174
Siraj Khan Avatar answered Oct 17 '22 19:10

Siraj Khan


Open your php.ini and find the [mail function] section

After that you have to change the options that are following and are relevant to your SMTP settings.

Settings to change :

SMTP = ; Enter here the address of your SMTP server smtp_port = 25 

Finaly from with your PHP script you have to use the mail function http://php.net/manual/en/function.mail.php

like image 31
KodeFor.Me Avatar answered Oct 17 '22 21:10

KodeFor.Me