Welcome Guest, Not a member yet? Register   Sign In
Problems using smtp mail
#1

[eluser]Russ Back[/eluser]
I'm new to CI so I hope this isn't a newbie no-brainer!

Basically I'm trying to send an email via smtp but I'm getting some php errors.

Here's my config code, everything in uppercase is a real value in my app:

Code:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mail.MYDOMAINHERE';
$config['smtp_user'] = 'MYUSERNAMEHERE';
$config['smtp_pass'] = 'MYPASSWORDHERE';

And here's my controller:

Code:
$this->load->library('email');
        
$this->email->from('EMAILEADDHERER', 'Website');
$this->email->to('TOADDRESS');
$this->email->bcc('BCCADDRESS');
$this->email->reply_to('REPLYTOADDRESS', 'Website');
        
$this->email->subject('Mailing list signup request');
$this->email->message($msg);
        
$this->email->send();

Pretty basic stuff, but I'm getting the following errors:

Quote:A PHP Error was encountered

Severity: Warning

Message: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known

Filename: libraries/Email.php

Line Number: 1646
A PHP Error was encountered

Severity: Warning

Message: fsockopen() [function.fsockopen]: unable to connect to mail.theclosestbureau.com:25 (php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known)

Filename: libraries/Email.php

Line Number: 1646
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1789
A PHP Error was encountered

Severity: Warning

Message: fgets(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1812
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1789
A PHP Error was encountered

Severity: Warning

Message: fgets(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1812
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1789
A PHP Error was encountered

Severity: Warning

Message: fgets(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1812
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1789
A PHP Error was encountered

Severity: Warning

Message: fgets(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1812
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1789
A PHP Error was encountered

Severity: Warning

Message: fgets(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1812
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1789
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1789
A PHP Error was encountered

Severity: Warning

Message: fgets(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1812

Any ideas what might be going wrong here??
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgntier community.

I am currently unable to ping your mail server or your domain name, so my guess is that this is a new host, and the information has not yet propagated up the DNS chain. I would recommend leaving it for 24-72 hours. Simply try pinging it, and once it resolves an IP address, you should be good to go, assuming that the domain name you're using is correct, and the mail subdomain exists.
#3

[eluser]SitesByJoe[/eluser]
I've also noticed that when using SMTP, you need to first set your config stuff in an array first, then do an "initialize" with your array as a parameter.

The syntax to do so is in the user guide on the email library page.

Not being to connect to the email server is a more obvious problem. My own troubles in the past with SMTP bring about the first statement.
#4

[eluser]Russ Back[/eluser]
The smtp server I'm connecting to is mail.theclosetbureau.com, which I believe is set to not respond to pings.

The config I've got is the same as using the initialize method - it's just stored in the config folder as a global config for all email functionality, rather than having it stored in each controller.
#5

[eluser]TheFuzzy0ne[/eluser]
The server doesn't need to respond to a ping to resolve to an IP address. Smile

You can see this if you try to ping microsoft.com
#6

[eluser]Russ Back[/eluser]
I think this might be a relay issue - when I run the script from www.theclosetbureau.com it works fine, but when I work in my localhost with the virtual host local.theclosetbureau.com, I get the errors.
#7

[eluser]Thiago Luiz[/eluser]
Hi, I'm using Smarty to send emails using SMTP by CodeIgniter. Try to download it and put the Smarty folder at the same level of the system folder. Then in your controller use something like this:


$ from = $ email; / * e-mail address * /
$ to = "[email protected]";
$ subject = "Message sent by IC";
$ message = "This is an example. I am trying to send via SMTP.

/ / Instance a new object of phpmailer
$ Mail = new PHPMailer ();

$ Email-> IsSMTP () / / send email by smtp

/ / Set language you prefer, the Portuguese br
$ Email-> SetLanguage ( "br");

/ / Active hmtl mail
$ Email-> IsHTML (true);

$ Email-> From = $ from;

/ / Sender address
$ Email-> FromName = "Name";

/ / Address of destination
$ Email-> AddAddress ($ a);

/ / Subject of the e-mail
$ Email-> Subject = $ subject;

/ / Body message, accepts html
$ Email-> Body = $ message, / / body of the message if HTML
/ / Html if message body is not supported
$ Email-> AltBody = $ message;

/ / Send mail
if (! $ Mail-> Send ()) (
/ / If the email has been sent to a page redirect error
$ this-> load-> view ( 'errors / email_not_sent', $ data);
)
else (
/ / If successful, redirects to a confirmation page
$ this-> load-> view ( 'accept / email_sent', $ data);
#8

[eluser]TheFuzzy0ne[/eluser]
[quote author="russback" date="1234924029"]I think this might be a relay issue - when I run the script from www.theclosetbureau.com it works fine, but when I work in my localhost with the virtual host local.theclosetbureau.com, I get the errors.[/quote]

www.theclosetbureau.com resolves for me when I ping it. The mail sub domain has also started resolving for me. If it doesn't work now, then it most likely is a relay issue of some sort.




Theme © iAndrew 2016 - Forum software by © MyBB