Any php function to send email without mail ()

I use mail () to send email with PHP without authentication.

This function only works on my web server, but does not work on the local machine.

I am looking for the best PHP function to send authentication email that will work on any machine without changing php.ini

I am using PHP with IIS and windows

thanks

+4
source share
5 answers

Another possibility is to set mail and net_smtp through a pear.

pear install Mail pear install Net_Smtp 

then you have the ability to send mail using SMTP authentication to another server:

 require_once "Mail.php"; $body = "Mein Mail Body\n"; $subject = "Mail mit SMTP Authentifizierung"; $mail_to = " zumir@meinemailserver.de "; $mail_from = " phpmailer@meinemailserver.de "; //SMTP Verbindungsdaten $host = "smtp.meinemailserver.de"; $username = "phpmailer"; $password = "SuperGeheim"; $smtp = Mail::factory('smtp', array ( 'host' => $host, 'auth' => true, 'username' => $username, 'password' => $password )); $headers = array ( 'From' => $mail_from, 'To' => $mail_to, 'Subject' => $subject ); $mail = $smtp->send($mail_to, $headers, $body); if (PEAR::isError($mail)) { echo "Fehler beim Versender der E-Mail : ". $mail->getMessage(); } 

(taken from http://www.jgeppert.com/2009/06/php-e-mail-mit-smtp-authentifizierung-versenden/ )

+3
source

You must start the local smtp server . This will allow mail() to work only if this program is running. There are other similar servers that will write mail to a file, so no mail goes to the development environment.

mail() is a way to send mail. you just have a configuration problem locally: D

+1
source

If you need a working SMTP server for testing in your own window, run this little guy in your mailbox so that you can check mail without changing your mail code.

http://www.softstack.com/freesmtp.html (free standalone simple stmp server)

0
source

I had this problem earlier this week and I found SwiftMailer . I only heard well about it. Worked well for me.

It can send via SMTP, sendmail or mail() . For local development, you will need to connect to the SMTP server that you run locally, or externally.

0
source

You can use the phpmailer library, go through the tutorial to install phpmailer, change the username, password, From and To address. Enjoy sending emails.

0
source

Source: https://habr.com/ru/post/1302912/


All Articles