Create email accounts using Postfix to send in WooCommerce

0

I have a site hosted on digitalocean. I configured the server with EasyEngine to install PHP, MySQL, Nginx, Postfix, WordPress, etc.

However, my WordPress is not sending e-mail, and because it is a store (WooCommerce), I need this function. So my question is: Do I need to create an email account in postfix so I can configure SMTP there in WordPress? Store email is currently allocated to the Google App.

    
asked by anonymous 01.04.2016 / 00:56

1 answer

2

I found it easier to use SwiftMailer to send emails.

I use this code in production:

$text = 'Olá Fulano';
$html = "<html>Olá <strong>Fulano de Tal</strong></html>";

$message = Swift_Message::newInstance()
  ->setSubject('Assunto')
  ->setFrom(array('[email protected]' => 'Remetente'))
  ->setTo(array('[email protected]'))
  ->setBody($text)
  ->addPart($html, 'text/html')
;

$transport = Swift_SmtpTransport::newInstance('ssl://smtp.gmail.com', 465)
  ->setUsername('[email protected]')
  ->setPassword('senha')
;
$mailer = Swift_Mailer::newInstance($transport);
$result = $mailer->send($message);

if (!$result)
    http_response_code(500);
    
01.04.2016 / 01:06