Git Product home page Git Product logo

Comments (14)

latanasov avatar latanasov commented on August 30, 2024 2

Hi @kimek we just released the improved version. You can update the library with composer update mailjet/mailjet-swiftmailer . Do let us know if you experience any other issues .

Regards,
Lyubo

from laravel-mailjet.

kimek avatar kimek commented on August 30, 2024 1

@Nightbr true, it didn't like Null.
I've added subject and name to email address and it works fine


$app->get('/mail', function () use ($app) {
    Mail::raw('Raw string email', function($msg) { 
           $msg->to(['{{clientEmailAddress}}']); 
           $msg->subject('{{subjectName}}); 
           $msg->setFrom(['{{emailAddress}}'=> '{{emailName}}']);
    });
});

Setting up only subject didn't fix issue. I've needed to add name to 'from-email'.

Thanks @Nightbr , thanks @latanasov

from laravel-mailjet.

Nightbr avatar Nightbr commented on August 30, 2024

Hi,

if you don't want to use the mail transport mailjet, you don't need the MAIL_XX config.
If you don't want to use the mail transport, don't add this to your providers array:
Mailjet\LaravelMailjet\MailjetMailServiceProvider::class,

Can you give us some code of your integration ?

from laravel-mailjet.

kimek avatar kimek commented on August 30, 2024

#env
MAIL_DRIVER=mailjet
MAIL_HOST=in-v3.mailjet.com
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

MAILJET_APIKEY={{ key }}
MAILJET_APISECRET={{ secret }}

#app.php

$app->configure('mail');
$app->configure('services');

$app->register(Mailjet\LaravelMailjet\MailjetServiceProvider::class);
$app->register(Mailjet\LaravelMailjet\MailjetMailServiceProvider::class);

#services.php

return [
'mailjet' => [
'key' => env('MAILJET_APIKEY'),
'secret' => env('MAILJET_APISECRET'),
]
];

#mail
return [

'driver' => env('MAIL_DRIVER', 'smtp'),

'host' => env('MAIL_HOST', 'smtp.mailgun.org'),

'port' => env('MAIL_PORT', 587),

'from' => ['address' => '[email protected]', 'name' => 'No Reply'],

'encryption' => env('MAIL_ENCRYPTION', 'tls'),

'username' => env('MAIL_USERNAME'),

'password' => env('MAIL_PASSWORD'),

'sendmail' => '/usr/sbin/sendmail -bs',

];

from laravel-mailjet.

Nightbr avatar Nightbr commented on August 30, 2024

Sounds good, in fact, you only need to set this config for Mailjet mail client works:

MAIL_DRIVER=mailjet
MAILJET_APIKEY={{ key }}
MAILJET_APISECRET={{ secret }}

from laravel-mailjet.

kimek avatar kimek commented on August 30, 2024

Thanks for fast replay @Nightbr

Mailhog works fine, Im trying to get mail now with Mailjet and nothing.

Double check key/secret.

In this case maybe there is issue with my docker <-> network.

I will check that. If there will be no comment below it means that it was firewall/network issue.

from laravel-mailjet.

Nightbr avatar Nightbr commented on August 30, 2024

Humm, can you copy/paste your code where you try to sent mail ?
Also make sure you have a valid and authorised from-address configured on your Mailjet account.

from laravel-mailjet.

kimek avatar kimek commented on August 30, 2024

Mail::raw('Raw string email', function($msg) { $msg->to(['test@{{ domain which is added to MJ }}']); $msg->from(['test@{{ domain which is added to MJ }}']); });

from laravel-mailjet.

Nightbr avatar Nightbr commented on August 30, 2024

ok, it should work so.
In order to debug deeper, you can try to var_dump() into vendor/mailjet/SwiftMailer/MailjetTransport.php into the send method, you can var_dump($this->resultApi); around line 140.

from laravel-mailjet.

kimek avatar kimek commented on August 30, 2024

var dump on

$this->resultApi = $this->mailjetClient->post(Resources::$Email, ['body' => $mailjetMessage]);

object(Mailjet\Response)#165 (5) {
  ["status":"Mailjet\Response":private]=>
  int(500)
  ["success":"Mailjet\Response":private]=>
  bool(false)
  ["body":"Mailjet\Response":private]=>
  NULL
  ["rawResponse":"Mailjet\Response":private]=>
  object(GuzzleHttp\Psr7\Response)#163 (6) {
    ["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=>
    string(35) "Cannot convert data from Null value"
    ["statusCode":"GuzzleHttp\Psr7\Response":private]=>
    int(500)
    ["headers":"GuzzleHttp\Psr7\Response":private]=>
    array(4) {
      ["Date"]=>
      array(1) {
        [0]=>
        string(29) "Mon, 17 Jul 2017 11:01:04 GMT"
      }
      ["Vary"]=>
      array(1) {
        [0]=>
        string(15) "Accept-Encoding"
      }
      ["Content-Length"]=>
      array(1) {
        [0]=>
        string(1) "0"
      }
      ["Content-Type"]=>
      array(1) {
        [0]=>
        string(9) "text/html"
      }
    }
    ["headerNames":"GuzzleHttp\Psr7\Response":private]=>
    array(4) {
      ["date"]=>
      string(4) "Date"
      ["vary"]=>
      string(4) "Vary"
      ["content-length"]=>
      string(14) "Content-Length"
      ["content-type"]=>
      string(12) "Content-Type"
    }
    ["protocol":"GuzzleHttp\Psr7\Response":private]=>
    string(3) "1.1"
    ["stream":"GuzzleHttp\Psr7\Response":private]=>
    object(GuzzleHttp\Psr7\Stream)#161 (7) {
      ["stream":"GuzzleHttp\Psr7\Stream":private]=>
      resource(6) of type (stream)
      ["size":"GuzzleHttp\Psr7\Stream":private]=>
      int(0)
      ["seekable":"GuzzleHttp\Psr7\Stream":private]=>
      bool(true)
      ["readable":"GuzzleHttp\Psr7\Stream":private]=>
      bool(true)
      ["writable":"GuzzleHttp\Psr7\Stream":private]=>
      bool(true)
      ["uri":"GuzzleHttp\Psr7\Stream":private]=>
      string(10) "php://temp"
      ["customMetadata":"GuzzleHttp\Psr7\Stream":private]=>
      array(0) {
      }
    }
  }
  ["request"]=>
  object(Mailjet\Request)#138 (7) {
    ["method":"Mailjet\Request":private]=>
    string(4) "POST"
    ["url":"Mailjet\Request":private]=>
    string(31) "https://api.mailjet.com/v3/send"
    ["filters":"Mailjet\Request":private]=>
    array(0) {
    }
    ["body":"Mailjet\Request":private]=>
    array(5) {
      ["FromEmail"]=>
      string(19) "{{mailAdress}}"
      ["FromName"]=>
      NULL
      ["Subject"]=>
      NULL
      ["Recipients"]=>
      array(1) {
        [0]=>
        array(2) {
          ["Email"]=>
          string(19) "{{mailAddress}}"
          ["Name"]=>
          NULL
        }
      }
      ["Text-part"]=>
      string(16) "Raw string email"
    }
    ["auth":"Mailjet\Request":private]=>
    array(2) {
      [0]=>
      string(32) "{{api_key}}"
      [1]=>
      string(32) "{{api secret}}
    }
    ["type":"Mailjet\Request":private]=>
    string(16) "application/json"
    ["config":"GuzzleHttp\Client":private]=>
    array(8) {
      ["defaults"]=>
      array(1) {
        ["headers"]=>
        array(1) {
          ["user-agent"]=>
          string(48) "mailjet-apiv3-php/7.0.15-0ubuntu0.16.04.4/v1.2.0"
        }
      }
      ["handler"]=>
      object(GuzzleHttp\HandlerStack)#139 (3) {
        ["handler":"GuzzleHttp\HandlerStack":private]=>
        object(Closure)#146 (2) {
          ["static"]=>
          array(2) {
            ["default"]=>
            object(Closure)#144 (2) {
              ["static"]=>
              array(2) {
                ["default"]=>
                object(GuzzleHttp\Handler\CurlMultiHandler)#140 (5) {
                  ["factory":"GuzzleHttp\Handler\CurlMultiHandler":private]=>
                  object(GuzzleHttp\Handler\CurlFactory)#141 (2) {
                    ["handles":"GuzzleHttp\Handler\CurlFactory":private]=>
                    array(0) {
                    }
                    ["maxHandles":"GuzzleHttp\Handler\CurlFactory":private]=>
                    int(50)
                  }
                  ["selectTimeout":"GuzzleHttp\Handler\CurlMultiHandler":private]=>
                  int(1)
                  ["active":"GuzzleHttp\Handler\CurlMultiHandler":private]=>
                  NULL
                  ["handles":"GuzzleHttp\Handler\CurlMultiHandler":private]=>
                  array(0) {
                  }
                  ["delays":"GuzzleHttp\Handler\CurlMultiHandler":private]=>
                  array(0) {
                  }
                }
                ["sync"]=>
                object(GuzzleHttp\Handler\CurlHandler)#142 (1) {
                  ["factory":"GuzzleHttp\Handler\CurlHandler":private]=>
                  object(GuzzleHttp\Handler\CurlFactory)#143 (2) {
                    ["handles":"GuzzleHttp\Handler\CurlFactory":private]=>
                    array(1) {
                      [0]=>
                      resource(8) of type (curl)
                    }
                    ["maxHandles":"GuzzleHttp\Handler\CurlFactory":private]=>
                    int(3)
                  }
                }
              }
              ["parameter"]=>
              array(2) {
                ["$request"]=>
                string(10) "<required>"
                ["$options"]=>
                string(10) "<required>"
              }
            }
            ["streaming"]=>
            object(GuzzleHttp\Handler\StreamHandler)#145 (1) {
              ["lastHeaders":"GuzzleHttp\Handler\StreamHandler":private]=>
              array(0) {
              }
            }
          }
          ["parameter"]=>
          array(2) {
            ["$request"]=>
            string(10) "<required>"
            ["$options"]=>
            string(10) "<required>"
          }
        }
        ["stack":"GuzzleHttp\HandlerStack":private]=>
        array(4) {
          [0]=>
          array(2) {
            [0]=>
            object(Closure)#147 (1) {
              ["parameter"]=>
              array(1) {
                ["$handler"]=>
                string(10) "<required>"
              }
            }
            [1]=>
            string(11) "http_errors"
          }
          [1]=>
          array(2) {
            [0]=>
            object(Closure)#148 (1) {
              ["parameter"]=>
              array(1) {
                ["$handler"]=>
                string(10) "<required>"
              }
            }
            [1]=>
            string(15) "allow_redirects"
          }
          [2]=>
          array(2) {
            [0]=>
            object(Closure)#149 (1) {
              ["parameter"]=>
              array(1) {
                ["$handler"]=>
                string(10) "<required>"
              }
            }
            [1]=>
            string(7) "cookies"
          }
          [3]=>
          array(2) {
            [0]=>
            object(Closure)#150 (1) {
              ["parameter"]=>
              array(1) {
                ["$handler"]=>
                string(10) "<required>"
              }
            }
            [1]=>
            string(12) "prepare_body"
          }
        }
        ["cached":"GuzzleHttp\HandlerStack":private]=>
        object(Closure)#158 (2) {
          ["static"]=>
          array(1) {
            ["handler"]=>
            object(GuzzleHttp\RedirectMiddleware)#157 (1) {
              ["nextHandler":"GuzzleHttp\RedirectMiddleware":private]=>
              object(Closure)#156 (2) {
                ["static"]=>
                array(1) {
                  ["handler"]=>
                  object(GuzzleHttp\PrepareBodyMiddleware)#154 (1) {
                    ["nextHandler":"GuzzleHttp\PrepareBodyMiddleware":private]=>
                    object(Closure)#146 (2) {
                      ["static"]=>
                      array(2) {
                        ["default"]=>
                        object(Closure)#144 (2) {
                          ["static"]=>
                          array(2) {
                            ["default"]=>
                            object(GuzzleHttp\Handler\CurlMultiHandler)#140 (5) {
                              ["factory":"GuzzleHttp\Handler\CurlMultiHandler":private]=>
                              object(GuzzleHttp\Handler\CurlFactory)#141 (2) {
                                ["handles":"GuzzleHttp\Handler\CurlFactory":private]=>
                                array(0) {
                                }
                                ["maxHandles":"GuzzleHttp\Handler\CurlFactory":private]=>
                                int(50)
                              }
                              ["selectTimeout":"GuzzleHttp\Handler\CurlMultiHandler":private]=>
                              int(1)
                              ["active":"GuzzleHttp\Handler\CurlMultiHandler":private]=>
                              NULL
                              ["handles":"GuzzleHttp\Handler\CurlMultiHandler":private]=>
                              array(0) {
                              }
                              ["delays":"GuzzleHttp\Handler\CurlMultiHandler":private]=>
                              array(0) {
                              }
                            }
                            ["sync"]=>
                            object(GuzzleHttp\Handler\CurlHandler)#142 (1) {
                              ["factory":"GuzzleHttp\Handler\CurlHandler":private]=>
                              object(GuzzleHttp\Handler\CurlFactory)#143 (2) {
                                ["handles":"GuzzleHttp\Handler\CurlFactory":private]=>
                                array(1) {
                                  [0]=>
                                  resource(8) of type (curl)
                                }
                                ["maxHandles":"GuzzleHttp\Handler\CurlFactory":private]=>
                                int(3)
                              }
                            }
                          }
                          ["parameter"]=>
                          array(2) {
                            ["$request"]=>
                            string(10) "<required>"
                            ["$options"]=>
                            string(10) "<required>"
                          }
                        }
                        ["streaming"]=>
                        object(GuzzleHttp\Handler\StreamHandler)#145 (1) {
                          ["lastHeaders":"GuzzleHttp\Handler\StreamHandler":private]=>
                          array(0) {
                          }
                        }
                      }
                      ["parameter"]=>
                      array(2) {
                        ["$request"]=>
                        string(10) "<required>"
                        ["$options"]=>
                        string(10) "<required>"
                      }
                    }
                  }
                }
                ["parameter"]=>
                array(2) {
                  ["$request"]=>
                  string(10) "<required>"
                  ["$options"]=>
                  string(10) "<required>"
                }
              }
            }
          }
          ["parameter"]=>
          array(2) {
            ["$request"]=>
            string(10) "<required>"
            ["$options"]=>
            string(10) "<required>"
          }
        }
      }
      ["allow_redirects"]=>
      array(5) {
        ["max"]=>
        int(5)
        ["protocols"]=>
        array(2) {
          [0]=>
          string(4) "http"
          [1]=>
          string(5) "https"
        }
        ["strict"]=>
        bool(false)
        ["referer"]=>
        bool(false)
        ["track_redirects"]=>
        bool(false)
      }
      ["http_errors"]=>
      bool(true)
      ["decode_content"]=>
      bool(true)
      ["verify"]=>
      bool(true)
      ["cookies"]=>
      bool(false)
      ["headers"]=>
      array(1) {
        ["User-Agent"]=>
        string(56) "GuzzleHttp/6.2.1 curl/7.47.0 PHP/7.0.15-0ubuntu0.16.04.4"
      }
    }
  }
}

from laravel-mailjet.

kimek avatar kimek commented on August 30, 2024

This works fine (just to inform)

curl -s \
  -X POST \
  --user "{{key}}" \
  https://api.mailjet.com/v3/send \
  -H 'Content-Type: application/json' \
  -d '{
    "FromEmail":"{{emailAddress}}",
    "Text-part":"Raw string email",
    "Recipients":[
        {
            "Email": "{{emailAddress}}"
        }
    ]
  }'

from laravel-mailjet.

Nightbr avatar Nightbr commented on August 30, 2024

@arnaudbreton, @latanasov, it seems like the API doesn't like NULL value:

Cannot convert data from Null value

Body request:

 ["body":"Mailjet\Request":private]=>
    array(5) {
      ["FromEmail"]=>
      string(19) "{{mailAdress}}"
      ["FromName"]=>
      NULL
      ["Subject"]=>
      NULL
      ["Recipients"]=>
      array(1) {
        [0]=>
        array(2) {
          ["Email"]=>
          string(19) "{{mailAddress}}"
          ["Name"]=>
          NULL
        }
      }
      ["Text-part"]=>
      string(16) "Raw string email"
    }

I think it can be better if the API could handle NULL value. But as a workaround, we can manage it into our SwiftMailerTransport...

@kimek try to add subject to your $msg:

$msg->subject('test');

https://laravel.com/api/5.3/Illuminate/Mail/Message.html

from laravel-mailjet.

kimek avatar kimek commented on August 30, 2024

@Nightbr
Same stuff:

object(Mailjet\Response)#165 (5) {
  ["status":"Mailjet\Response":private]=>
  int(500)
  ["success":"Mailjet\Response":private]=>
  bool(false)
  ["body":"Mailjet\Response":private]=>
  NULL
  ["rawResponse":"Mailjet\Response":private]=>
  object(GuzzleHttp\Psr7\Response)#163 (6) {
    ["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=>
    string(35) "Cannot convert data from Null value"
    ["statusCode":"GuzzleHttp\Psr7\Response":private]=>
    int(500)
    ["headers":"GuzzleHttp\Psr7\Response":private]=>
    array(4) {
      ["Date"]=>
      array(1) {
        [0]=>
        string(29) "Mon, 17 Jul 2017 11:30:53 GMT"
      }
      ["Vary"]=>
      array(1) {
        [0]=>
        string(15) "Accept-Encoding"
      }
      ["Content-Length"]=>
      array(1) {
        [0]=>
        string(1) "0"
      }
      ["Content-Type"]=>
      array(1) {
        [0]=>
        string(9) "text/html"
      }
    }
    ["headerNames":"GuzzleHttp\Psr7\Response":private]=>
    array(4) {
      ["date"]=>
      string(4) "Date"
      ["vary"]=>
      string(4) "Vary"
      ["content-length"]=>
      string(14) "Content-Length"
      ["content-type"]=>
      string(12) "Content-Type"
    }
    ["protocol":"GuzzleHttp\Psr7\Response":private]=>
    string(3) "1.1"
    ["stream":"GuzzleHttp\Psr7\Response":private]=>
    object(GuzzleHttp\Psr7\Stream)#161 (7) {
      ["stream":"GuzzleHttp\Psr7\Stream":private]=>
      resource(5) of type (stream)
      ["size":"GuzzleHttp\Psr7\Stream":private]=>
      int(0)
      ["seekable":"GuzzleHttp\Psr7\Stream":private]=>
      bool(true)
      ["readable":"GuzzleHttp\Psr7\Stream":private]=>
      bool(true)
      ["writable":"GuzzleHttp\Psr7\Stream":private]=>
      bool(true)
      ["uri":"GuzzleHttp\Psr7\Stream":private]=>
      string(10) "php://temp"
      ["customMetadata":"GuzzleHttp\Psr7\Stream":private]=>
      array(0) {
      }
    }
  }

from laravel-mailjet.

latanasov avatar latanasov commented on August 30, 2024

@Nightbr @kimek , I'll fix the NULL value issue on the SwiftMailerTransport side. I think we already have a bug reported on the API backend.

@kimek could you try setting Subject, From name and To name to an empty string for example ("") and say if the issue is resolved.

from laravel-mailjet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.