Forum Stats

  • 3,767,858 Users
  • 2,252,726 Discussions
  • 7,874,366 Comments

Discussions

cant send email with mailgun

User_A53JT
User_A53JT Member Posts: 1 Employee

Hello

im unable to send email from a compute instance in OCI using mailgun for php

mailgun told me that it sould be the server, this same code runs Ok in another server (GCP), but it only fails in my OCI instances. Please please help me!

Error:

Failed to connect to smtp.mailgun.org:465 [SMTP: Failed to connect socket: Permission denied (code: -1, response: )] )

code:

$host = "smtp.mailgun.org";

$username = "[email protected]";

$password = "mypass";

$port = "465";


$to = "[email protected]";

$email_from = "[email protected]";

$email_address = "[email protected]";

$content = "text/html; charset=utf-8";

$mime = "1.0";

$random = uniqid();


$email_subject ="yest";


  $params = array  ('host' => $host,

  'port' => $port,

  'auth' => true,

  'username' => $username,

  'password' => $password);

$smtp = Mail::factory ('smtp', $params);


/*

  $mail->addReplyTo('[email protected]', 'Admin Actas');

  //Set who the message is to be sent to

  $mail->addAddress('[email protected]', 'Admin Actas ');

*/

  //Set the subject line

  $random = uniqid();

  $html = "<h1> Nuevo pedidio Gel Antibacterial</h1><br>";

    $email_body =$html;


    $headers = array ('From' => $email_from,

'To' => $to,

'Subject' => $email_subject,

'Reply-To' => $email_address,

'MIME-Version' => $mime,

'Content-type' => $content);


$params = array  ('host' => $host,

'port' => $port,

'auth' => true,

'username' => $username,

'password' => $password);

$smtp = Mail::factory ('smtp', $params);

$mail = $smtp->send($to, $headers, $email_body);

Tagged:

Answers