How to Configure Xampp to Send Mail from Localhost

How can I Setup XAMPP for SMTP outgoing Email on a UNIX machine

First install a sendmail

sudo apt-get install sendmail

In the php.ini file find [mail function] and change it as follows:

    SMTP=smtp.gmail.com
smtp_port=587
sendmail_from=your@gmail.com
sendmail_path=/usr/sbin/sendmail -t -i
  • Windows

    Now edit the `sendmail.ini`:

    [sendmail]
    smtp_server=smtp.gmail.com
    smtp_port=587
    error_logfile=error.log
    debug_logfile=debug.log
    auth_username=username@gmail.com
    auth_password=gmail-password
    force_sender=username@gmail.com
  • Linux

    Once you have installed sendmail you can run following command: sudo sendmailconfig. Answer [Y] to all questions.

    Make new directory:

     sudo mkdir -m 700 /etc/mail/authinfo && cd /etc/mail/authinfo

    Create new file:

     sudo touch ./gmail-auth

    Insert following content:

     AuthInfo: "U:YOUR ACCOUNT NAME" "I:YOUR GMAIL EMAIL ADDRESS" "P:YOUR GMAIL PASSWORD"

    Create new hash map:

     makemap hash gmail-auth < gmail-auth

    Open /etc/mail/sendmail.mc and above first MAILER definition add:

     define(`SMART_HOST',`[smtp.gmail.com]')dnl
    define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
    define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
    define(`confAUTH_OPTIONS', `A p')dnl
    TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
    define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
    FEATURE(`authinfo',`hash -o /etc/mail/authinfo/gmail-auth')dnl

    Rebuild configuration and restart sendmail service

      sudo make -C /etc/mail && sudo service sendmail restart
  • macOS

    Install homebrew and sendmail with brew install sendmail In order to get the installation dir execute following command: brew info sendmail. Do the same configuration steps from the Linux part of this answer.

Sending email from localhost server xampp/sendmail

Try this

sendmail.ini

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=ssl
error_logfile=error.log
debug_logfile=debug.log
auth_username=[email]@gmail.com
auth_password=[email password]
pop3_server=
pop3_username=
pop3_password=
force_sender=[email]@gmail.com
force_recipient=
hostname=smtp.gmail.com

php.ini

[mail function]

SMTP = smtp.gmail.com
smtp_port = 465
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=Off


Related Topics



Leave a reply



Submit