serving the solutions day and night

Pages

Sunday, December 25, 2011

Send Email in PHP using GMAIL SMTP Server

Sendmail
  1. Download and Unzip: download sendmail.zip
  2. Open Sendmail.ini in text editor
    Change the following options Sendmail.ini and save.
    smtp_server=smtp.gmail.com

    smtp_port=587

    auth_username=<email_name>@gmail.com
    auth_password=<email_password>

    force_sender=<email_name>@gmail.com
  3. Open your PHP configuration (PHP.ini), Edit and Save:
    [mail function]
    ; For Win32 only.
    ; http://php.net/smtp
    ;SMTP = localhost

    ; http://php.net/smtp-port
    ;smtp_port = 25

    ; For Win32 only.
    ; http://php.net/sendmail-from
    ;sendmail_from = me@example.com

    ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
    ; http://php.net/sendmail-path
    sendmail_path ="C:\DNS\Projects\sendmail\sendmail.exe -t"

    ; Force the addition of the specified parameters to be passed as extra parameters
    ; to the sendmail binary. These parameters will always replace the value of
    ; the 5th parameter to mail(), even in safe mode.
    ;mail.force_extra_parameters =
Stunnel
  1. Download and Install: stunnel-4.54-installer.exe 
  2. In start menu, go to stunnel folder and click on 'Edit stunnel.conf'
    Uncomment the following options stunnel.conf and save.
    debug = 7
    output = stunnel.log

    cert = stunnel.pem

    [gmail-smtp]
    client = yes
    accept = 127.0.0.1:25
    connect = smtp.gmail.com:465
  3. In start menu, go to stunnel folder and click 'Run stunnel' and Start 'Service Start'.
  4. Option to Configure Sendmail to Stunnel, Go edit sendmail.ini and change to the following:
    smtp_server=localhost and smtp_port=25

No comments: