dlm423
dlm423

Reputation: 41

Unable to connect to smtp (Connection refused)

I looked around and there are a lot of questions on this issue, but I guess they are all somewhat specific and none seem to have the info I'm looking for.

We recently added the email function to our site so that we can send out automated emails to people who register, forget passwords, etc. This is set up properly and works fine on the Localhost.

We then pushed the site to a web server and it is not working. We get the following error message:

fsockopen() [function.fsockopen]: unable to connect to smtp.sendgrid.net:587 (Connection refused)

Followed by a bunch of other errors related to functions that depend on the above connection happening. We've tried ports 587, 25, and 2525 but no luck.

This is the code:

$this->load->library('email');

$this->email->initialize(array(
    'protocol' => 'smtp',
    'smtp_host' => 'smtp.sendgrid.net',
    'smtp_user' => 'username',
    'smtp_pass' => 'secretpwd',
    'smtp_port' => 587,
    'crlf' => "\r\n",
    'newline' => "\r\n",
    'mailtype' => 'html'
));

$this->email->from('[email protected]', 'CompanyName');
$this->email->to($this->input->post('register_email')); 

$this->email->subject('Application Confirmation');

$this->email->message('Hello');

$this->email->send()

Upvotes: 2

Views: 6842

Answers (1)

pregmatch
pregmatch

Reputation: 2657

You have open relay on your domain!!!!!!! If you are using postfix please update your main configuration file to this

smtpd_recipient_restrictions = 
    reject_unknown_recipient_domain
    permit_sasl_authenticated
    reject_unauth_destination #this is important
    permit 
    smtpd_sender_restrictions = reject_unknown_sender_domain

As far as your question goes show me some code. It is hard just from this to make coclusion what is wrong.

Upvotes: 4

Related Questions