在php里从本地经过msmtp发送邮件
在php里从本地通过msmtp发送邮件
参看http://www.absolutelytech.com/2010/07/18/howto-send-emailsusing-mail-function-from-localhost-in-php-through-msmtp-using-gmail-account-on-linux/?的步骤:
?
?
Step by step instructions:
?
- First of all, follow this tutorial:
Install msmtp on your linux box and configure it to work with Gmail.?
Msmtp is highly configurable and you can easily configure it to work with any smtp server. If you wish to use any other service with msmtp, you may?read its manual?and configure it.
Proceed to next step only if you have successfully configured and are able to send a test message. - Open php.ini in your text editor.
<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #c20cb9; font-weight: bold;">sudo</span> gedit <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #000000; font-weight: bold;">/</span>etc<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #000000; font-weight: bold;">/</span>php5<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #000000; font-weight: bold;">/</span>apache2<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #000000; font-weight: bold;">/</span>php.ini
Nach dem Login kopierenSearch for ‘sendmail_path’ and change it to look like
sendmail_path = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #ff0000;">'/usr/bin/msmtp -t'</span>
Nach dem Login kopierenSave the file and exit the text editor.
Please note that your msmtp path may vary if you are not using Ubuntu. You may find the path to executable by:<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #c20cb9; font-weight: bold;">which</span> msmtp
Nach dem Login kopieren- Restart apache:
?
<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #c20cb9; font-weight: bold;">sudo</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #000000; font-weight: bold;">/</span>etc<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #000000; font-weight: bold;">/</span>init.d<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #000000; font-weight: bold;">/</span>apache2 restart
Nach dem Login kopierenOR
<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #c20cb9; font-weight: bold;">sudo</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #000000; font-weight: bold;">/</span>opt<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #000000; font-weight: bold;">/</span>lampp<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #000000; font-weight: bold;">/</span>lampp restart
Nach dem Login kopieren- Everything’s done. Lets test if the mail() function is working now:
<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #b1b100;">if</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #009900;">(</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #990000;">mail</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #009900;">(</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #0000ff;">[email protected]'</span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #339933;">,</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #0000ff;">'Test mail from localhost'</span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #339933;">,</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #0000ff;">'Working Fine.'</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #009900;">)</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #009900;">)</span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #339933;">;</span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #b1b100;">echo</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #0000ff;">'Mail sent'</span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #339933;">;</span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #b1b100;">else</span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #b1b100;">echo</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #0000ff;">'Error. Please check error log.'</span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #339933;">;</span>
Nach dem Login kopierenReplace the [email protected] with your own username, save it into a php file along with php delimeters in your virtual host root folder and execute it through the browser. You should receive a mail.
跟上述步骤大同小异。
msmtp在ubuntu下apt-get install msmtp就可以安装, 安装完后, msmtp --ver 查看:
......
?
System configuration file name: /etc/msmtprc
User configuration file name: /root/.msmtprc
显然要保证有/etc/msmtprc文件并要设置好它的配置内容。我的/etc/msmtprc内容如下:# Set default values for all following accounts.
defaults
logfile /usr/local/msmtp/msmtp.log
# The SMTP server of the provider.
account test
# SMTP邮件服务器地址
host smtp.ym.163.com
# 发送的邮件Email
from [email protected]
auth login
# 邮件服务器登录账号
user [email protected]
# 邮件服务器登陆密码
password 12345678
# Set a default account
account default : test
不过,我打开上面的测试php时,开始时出来Error. Please check error log.
发送邮件不成功,查看apache的error_log, 找到错误信息:
msmtp: /etc/msmtprc: must be owned by you
原来是/etc/msmtprc的权限是777的话也不行,需要限制。 ps aux|grep httpd查看apache的进程的用户名是www,
然后:
chown www.www /etc/msmtprc
chmod 600 /etc/msmtprc # 一定要600而不是777 !
搞定!然后在mantis里配置?$g_phpMailer_method ? ? ? ? ? ? = PHPMAILER_METHOD_MAIL这样比配置 PHPMAILER_METHOD_SMTP 发邮件要快得多,都可立即收到邮件!?
?
Erklärung dieser WebsiteDer Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cnHeiße KI -Werkzeuge
Undresser.AI Undress
KI-gestützte App zum Erstellen realistischer Aktfotos
AI Clothes Remover
Online-KI-Tool zum Entfernen von Kleidung aus Fotos.
Undress AI Tool
Ausziehbilder kostenlos
Clothoff.io
KI-Kleiderentferner
AI Hentai Generator
Erstellen Sie kostenlos Ai Hentai.
Heißer Artikel
R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)2 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌Repo: Wie man Teamkollegen wiederbelebt4 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌Hello Kitty Island Abenteuer: Wie man riesige Samen bekommt4 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌Wie lange dauert es, um Split Fiction zu schlagen?3 Wochen vor By DDDR.E.P.O. Dateispeicherspeicherort: Wo ist es und wie schützt sie?3 Wochen vor By DDDHeiße Werkzeuge
Notepad++7.3.1
Einfach zu bedienender und kostenloser Code-Editor
SublimeText3 chinesische Version
Chinesische Version, sehr einfach zu bedienen
Senden Sie Studio 13.0.1
Leistungsstarke integrierte PHP-Entwicklungsumgebung
Dreamweaver CS6
Visuelle Webentwicklungstools
SublimeText3 Mac-Version
Codebearbeitungssoftware auf Gottesniveau (SublimeText3)
Heiße Themen
Leistungsvergleich des PHP-Frameworks: Der ultimative Showdown zwischen Geschwindigkeit und Effizienz Apr 30, 2024 pm 12:27 PM
Laut Benchmarks zeichnet sich Laravel durch Seitenladegeschwindigkeit und Datenbankabfragen aus, während CodeIgniter sich durch Datenverarbeitung auszeichnet. Bei der Auswahl eines PHP-Frameworks sollten Sie die Anwendungsgröße, die Verkehrsmuster und die Fähigkeiten des Entwicklungsteams berücksichtigen.
Wie führt man Parallelitätstests und Debugging in der Java-Parallelprogrammierung durch? May 09, 2024 am 09:33 AM
Parallelitätstests und Debugging Parallelitätstests und Debugging in der gleichzeitigen Java-Programmierung sind von entscheidender Bedeutung und die folgenden Techniken stehen zur Verfügung: Parallelitätstests: Unit-Tests: Isolieren und testen Sie eine einzelne gleichzeitige Aufgabe. Integrationstests: Testen der Interaktion zwischen mehreren gleichzeitigen Aufgaben. Lasttests: Bewerten Sie die Leistung und Skalierbarkeit einer Anwendung unter hoher Last. Parallelitäts-Debugging: Haltepunkte: Thread-Ausführung anhalten und Variablen überprüfen oder Code ausführen. Protokollierung: Thread-Ereignisse und -Status aufzeichnen. Stack-Trace: Identifizieren Sie die Quelle der Ausnahme. Visualisierungstools: Überwachen Sie die Thread-Aktivität und die Ressourcennutzung.
Das Evasive-Modul schützt Ihre Website vor DOS-Angriffen auf Anwendungsebene Apr 30, 2024 pm 05:34 PM
Es gibt eine Vielzahl von Angriffsmethoden, die eine Website offline schalten können. Die komplexeren Methoden erfordern technische Kenntnisse in Datenbanken und Programmierung. Eine einfachere Methode wird als „DenialOfService“-Angriff (DOS) bezeichnet. Der Name dieser Angriffsmethode leitet sich von ihrer Absicht ab, normale Serviceanfragen von normalen Kunden oder Website-Besuchern abzulehnen. Im Allgemeinen gibt es zwei Formen von DOS-Angriffen: die dritte und vierte Schicht des OSI-Modells, d. h. den Netzwerkschicht-Angriff. Die siebte Schicht des OSI-Modells, d. h. den Anwendungsschicht-Angriff Angriff – die Netzwerkschicht, tritt auf, wenn eine große Menge Junk-Datenverkehr zum Webserver fließt. Wenn der Spam-Verkehr die Fähigkeit des Netzwerks übersteigt, ihn zu verarbeiten, stürzt die Website ab. Die zweite Art von DOS-Angriff erfolgt auf der Anwendungsebene und nutzt kombinierte Angriffe
So fügen Sie einen Server in Eclipse hinzu May 05, 2024 pm 07:27 PM
Um einen Server zu Eclipse hinzuzufügen, führen Sie die folgenden Schritte aus: Erstellen Sie eine Serverlaufzeitumgebung. Konfigurieren Sie den Server. Erstellen Sie eine Serverinstanz. Wählen Sie die Serverlaufzeitumgebung aus. Konfigurieren Sie die Serverinstanz. Starten Sie das Serverbereitstellungsprojekt
Anwendung von Algorithmen beim Aufbau einer 58-Porträt-Plattform May 09, 2024 am 09:01 AM
1. Hintergrund des Baus der 58-Portrait-Plattform Zunächst möchte ich Ihnen den Hintergrund des Baus der 58-Portrait-Plattform mitteilen. 1. Das traditionelle Denken der traditionellen Profiling-Plattform reicht nicht mehr aus. Der Aufbau einer Benutzer-Profiling-Plattform basiert auf Data-Warehouse-Modellierungsfunktionen, um Daten aus mehreren Geschäftsbereichen zu integrieren, um genaue Benutzerporträts zu erstellen Und schließlich muss es über Datenplattformfunktionen verfügen, um Benutzerprofildaten effizient zu speichern, abzufragen und zu teilen sowie Profildienste bereitzustellen. Der Hauptunterschied zwischen einer selbst erstellten Business-Profiling-Plattform und einer Middle-Office-Profiling-Plattform besteht darin, dass die selbst erstellte Profiling-Plattform einen einzelnen Geschäftsbereich bedient und bei Bedarf angepasst werden kann. Die Mid-Office-Plattform bedient mehrere Geschäftsbereiche und ist komplex Modellierung und bietet allgemeinere Funktionen. 2.58 Benutzerporträts vom Hintergrund der Porträtkonstruktion im Mittelbahnsteig 58
So stellen Sie eine Website mit PHP bereit und pflegen sie May 03, 2024 am 08:54 AM
Um eine PHP-Website erfolgreich bereitzustellen und zu warten, müssen Sie die folgenden Schritte ausführen: Wählen Sie einen Webserver (z. B. Apache oder Nginx). Installieren Sie PHP. Erstellen Sie eine Datenbank und verbinden Sie PHP. Laden Sie Code auf den Server hoch. Richten Sie den Domänennamen und die DNS-Überwachung der Website-Wartung ein Zu den Schritten gehören die Aktualisierung von PHP und Webservern sowie die Sicherung der Website, die Überwachung von Fehlerprotokollen und die Aktualisierung von Inhalten.
So schützen Sie Ihren Server mit Fail2Ban vor Brute-Force-Angriffen Apr 27, 2024 am 08:34 AM
Eine wichtige Aufgabe für Linux-Administratoren besteht darin, den Server vor illegalen Angriffen oder Zugriffen zu schützen. Linux-Systeme verfügen standardmäßig über gut konfigurierte Firewalls wie iptables, Uncomplicated Firewall (UFW), ConfigServerSecurityFirewall (CSF) usw., die eine Vielzahl von Angriffen verhindern können. Jeder mit dem Internet verbundene Computer ist ein potenzielles Ziel für böswillige Angriffe. Es gibt ein Tool namens Fail2Ban, mit dem illegale Zugriffe auf den Server eingedämmt werden können. Was ist Fail2Ban? Fail2Ban[1] ist eine Intrusion-Prevention-Software, die Server vor Brute-Force-Angriffen schützt. Es ist in der Programmiersprache Python geschrieben
So implementieren Sie Best Practices für die PHP-Sicherheit May 05, 2024 am 10:51 AM
So implementieren Sie Best Practices für die PHP-Sicherheit PHP ist eine der beliebtesten Backend-Webprogrammiersprachen, die zum Erstellen dynamischer und interaktiver Websites verwendet wird. Allerdings kann PHP-Code verschiedene Sicherheitslücken aufweisen. Um Ihre Webanwendungen vor diesen Bedrohungen zu schützen, ist die Implementierung bewährter Sicherheitspraktiken von entscheidender Bedeutung. Eingabevalidierung Die Eingabevalidierung ist ein wichtiger erster Schritt zur Validierung von Benutzereingaben und zur Verhinderung böswilliger Eingaben wie SQL-Injection. PHP bietet eine Vielzahl von Eingabevalidierungsfunktionen, wie zum Beispiel filter_var() und preg_match(). Beispiel: $username=filter_var($_POST['username'],FILTER_SANIT
- Restart apache: