Create email accounts using Postfix to send on Woocommerce

Asked

Viewed 265 times

0

I have a website hosted on digitalocean. I have configured the server with Easyengine for installation of PHP, Mysql, Nginx, Postfix, Wordpress, etc.

However, my Wordpress is not sending email, and as it comes to a store (Woocommerce), I need this function. So my question is: Do I need to create an email account in postfix in order to configure SMTP there in Wordpress? Currently the store email is allocated in Google App.

1 answer

1

I found it easier to use the 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);
  • 1

    I think the idea is "let those who know about email take care of your email". Can you do it on your arm? Gives. But, wow, there’s so much else to do :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.