3

I have a question which might be a bit stupid, but I can not cope with my problem : I am developing an App where I have to send emails to the users, that's why I am using the PHPMailer library. I tested the application with Google's smtp server and the emails are delivered as expected. Now I installed mailcatcher in order to test my emails locally, but I have no idea how to do it. In the documentation of mailcatcher is written: Send mail through smtp://localhost:1025 How to do this with PHPMailer? Currently I have :

'SMTPDebug'=> 2 ,
'Host' => 'smtp.gmail.com',
'Username'=>'XXXX@gmail.com',
'Password'=>'XXXXXX',
'SMTPSecure'=>'tls',
'Port'=>587,
'From'=> 'test',
'FromName'=> 'test',
'Subject'=>'test',
'IsHTML'=>true

What do I need to change? I tried changng the host to smtp://localhost:1025 , but messages are not delivered. Thank you !

Teo
  • 67
  • 5

2 Answers2

3

This seems like the most likely 2 things to change

'SMTPDebug'=> 2 ,
//'Host' => 'smtp.gmail.com',
'Host' => '127.0.0.1',
'Username'=>'XXXX@gmail.com',
'Password'=>'XXXXXX',
'SMTPSecure'=>'tls',
//'Port'=>587,
'Port'=>1025,
'From'=> 'test',
'FromName'=> 'test',
'Subject'=>'test',
'IsHTML'=>true

You may also need to remove

SMTPSecure'=>'tls',

depending on how clever mailcather is

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
0

Very easy set the port to 1025 and the host to localhost.

'SMTPDebug'=> 2 ,
'Host' => 'localhost',
'Username'=>'XXXX@gmail.com',
'Password'=>'XXXXXX',
'SMTPSecure'=>'tls',
'Port'=>1025,
'From'=> 'test',
'FromName'=> 'test',
'Subject'=>'test',
'IsHTML'=>true

mailcatcher listen to that port and catch all emails on that port.

Local scripts can then connect to SMTP at localhost port 1025. Additionally, the web interface is available at port 1080 by default."

perhaps you have to disable TLS to work work with mailcatcher if the connection doesn't accept TLS.

René Höhle
  • 26,716
  • 22
  • 73
  • 82