PortalKundewebMailadmin
Language
 
Home>Knowledge Base>Webutvikling>SMTP med autentisering i PHP og Wordpress
User Login
Username
Password
 
 Login
Information
Article ID186
Created On11/9/2011
Modified11/16/2011
Share With Others

SMTP med autentisering i PHP og Wordpress

For wordpress bruker man "WP Mail SMTP" plugin, som skriver om wp_mail funksjon
til å autentisere via smtp.

For ren php:

<?php require_once "Mail.php"; $from = "test tester <test@tester.com>"; $to = "Mottak mottaker <mottaker@test.com>"; $subject = "hei"; $body = "Hei,\n\nbestilling?"; $host = "mail.dittdomenenavn.no"; $username = "dinepost@dittdomenenavn.no"; $password = "passordetforepostendusenderfra"; $headers = array ('From' => $from,   'To' => $to,   'Subject' => $subject); $smtp = Mail::factory('smtp',   array ('host' => $host,     'auth' => true,     'username' => $username,     'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) {   echo("<p>" . $mail->getMessage() . "</p>");  } else {   echo("<p>Message successfully sent!</p>");  } ?>