Welcome Guest, Not a member yet? Register   Sign In
Unable to send emails with MAMP
#1

[eluser]Wit07[/eluser]
Hi there,

After several hours seeking on the web, I didn't solve my issue: I can't send emails using CI running on MAMP free.

Here is my config:

Code:
$config = array();
  $config['protocol'] = "smtp";
  $config['smtp_host'] = "ssl://smtp.gmail.com";
  $config['smtp_port'] = "465";
  $config['smtp_user'] = "******";
  $config['smtp_pass'] = "******";
  $config['mailtype'] = "text";
  $config['charset']  = "utf-8";
  $config['starttls'] = TRUE;
  
  $this->load->library('email', $config);
  
  $this->email->from('******');
  $this->email->to($email);
  $this->email->subject($title);
  $this->email->message($content);
  
  $this->email->send();

I got an infinitive loop and nothing is printed into my log... I enabled SSL on MAMP and added these lines to php.ini:

Code:
[mail function]
; For Win32 only.
SMTP = ssl://smtp.gmail.com
smtp_port = 465

; For Win32 only.
sendmail_from = ******

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path =/usr/sbin/sendmail -t -i -f ******

Also, a command line such as
Code:
echo "test" | mail -s "subject" [email protected]
works fine.

Do you have any idea?

Cheers
#2

[eluser]ortwin.van.vessem[/eluser]
Please read this blog post to enable postfix: http://benjaminrojas.net/configuring-pos...tain-lion/

This was the solution for me.
#3

[eluser]Wit07[/eluser]
Thank for your answer ortwin.van.vessem.

Now I get an error into my log: Failed to send AUTH LOGIN command. Error: 530 5.7.0 Must issue a STARTTLS command first. a1sm58176507eem.1 - gsmtp

Can you tell me how did you set up your different files (php.ini, main.cf and CI source file)?
#4

[eluser]Wit07[/eluser]
Finally I found the solution:

Send emails with MAMP (mail() PHP function)

1. Set up SSL: http://soundsplausible.com/2012/01/14/en...amp-2-0-5/

2. Set up Postfix: http://benjaminrojas.net/configuring-pos...tain-lion/

3. Into MAMP's php.ini (glance phpinfo() to know which version is used and conclude into which folder you need to edit), comment lines SMTP, smtp_port and sendmail_from. Uncomment line sendmail_path and set /usr/sbin/sendmail -t -i as new value.

You should be able to send emails now, if PostFix works fine (run test given in tutorial above).

Send emails with CI

To send emails with CI, you don't need to write your logins into a file for PostFix. However, you need to be able to run PostFix and SSL.

Here is an example of config file for a google account:

Code:
$config['protocol'] = "smtp";
  $config['smtp_host'] = "smtp.gmail.com";
  $config['smtp_port'] = "587";
  $config['smtp_user'] = "*****";
  $config['smtp_pass'] = "*****";
  $config['smtp_crypto'] = "tls"; //very important line, don't remove it
  $config['smtp_timeout'] = "5"; //google hint
  $config['mailtype'] = "text";
  $config['charset']  = "utf-8";
  $config['newline'] = "\r\n";


Be careful with " " which are necessary, ' ' could create issues. Here I'm using a TLS connection. If you prefer SSL, use port 465 and fix correctly smtp_crypto value.




Theme © iAndrew 2016 - Forum software by © MyBB