Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
php mail() nie dziala z ssmtp i gmail
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish)
View previous topic :: View next topic  
Author Message
galandilias
n00b
n00b


Joined: 03 Jul 2011
Posts: 47

PostPosted: Tue Jan 29, 2013 6:24 pm    Post subject: php mail() nie dziala z ssmtp i gmail Reply with quote

Czesc,

Mam problem z poprawna konfiguracja php ssmtp i gmaila. Pobralem i skonfigurowalem ssmtp wydaje mi sie poprawnie poniewaz odpalone z bash:
Code:
echo "This is a test" | mail -s "Test" mail@gmail.com

wysyla pieknie maila, za to jak probuje z takiego php
Code:
<?php

$res = mail ( "mail@gmail.com", "Test" , "Hello World!" );
var_export( $res );

?>

odpalic wyslanie maila to dostaje takie cos w logach:
Code:
Jan 29 19:19:45 mnet-proliant apache2: mail() on [/var/www/localhost/htdocs/test.php:3]: To: mail@gmail.com -- Headers:
Jan 29 19:19:45 mnet-proliant sSMTP[17353]: Creating SSL connection to host
Jan 29 19:19:45 mnet-proliant sSMTP[17353]: 220 mx.google.com ESMTP b2sm21276967eep.9 - gsmtp
Jan 29 19:19:45 mnet-proliant sSMTP[17353]: EHLO nowakmarcin.com
Jan 29 19:19:45 mnet-proliant sSMTP[17353]: 250 ENHANCEDSTATUSCODES
Jan 29 19:19:45 mnet-proliant sSMTP[17353]: STARTTLS
Jan 29 19:19:45 mnet-proliant sSMTP[17353]: 220 2.0.0 Ready to start TLS
Jan 29 19:19:45 mnet-proliant sSMTP[17353]: Cannot open smtp.gmail.com:587


konfiguracja ssmtp.conf:
Code:
root=postman@nowakmarcin.com
mailhub=smtp.gmail.com:587
AuthUser=postman@nowakmarcin.com
AuthPass=mypass
UseSTARTTLS=YES
rewriteDomain=nowakmarcin.com
hostname=nowakmarcin.com
FromLineOverride=YES
UseTLS=YES
Debug=YES


konfiguracja php.ini:
Code:
sendmail_path = "/usr/sbin/ssmtp -t -i"
mail.add_x_header = On
mail.log = syslog


Prosze o pomoc bo juz mi sie pomysly wyczerpaly :)

PS. konfiguracja jak widac w plikach jest w oparciu o apps.google.com - tam mam skrzynke
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2831

PostPosted: Wed Jan 30, 2013 6:56 pm    Post subject: Reply with quote

User na ktorym pracuje php/apache ma dostep do sieci? Sprawdz z niego.
_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
galandilias
n00b
n00b


Joined: 03 Jul 2011
Posts: 47

PostPosted: Thu Jan 31, 2013 6:21 am    Post subject: Reply with quote

a jak to zrobic? :) nie moge zrobic
Code:
su apache
bo to konto jest nologin
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2831

PostPosted: Thu Jan 31, 2013 10:51 am    Post subject: Reply with quote

su apache --shell=/bin/bash powinno zadzialac. Nie masz jakis zaczarowanych regulek iptables tam? Moze apache pracuje w chroocie, w ktorym nie ma libnss przez co nie potrafi zresolvowac DNS'a i koniec koncow konczy sie na takim bledzie?
_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
galandilias
n00b
n00b


Joined: 03 Jul 2011
Posts: 47

PostPosted: Thu Jan 31, 2013 12:39 pm    Post subject: Reply with quote

ok z apache mail nie idzie :)

Code:
SSL_connect: Success
send-mail: Cannot open smtp.gmail.com:587
Can't send mail: sendmail process failed with error code 1


co dalej? :)

Apache raczej nie pracuje na chroot w iptables tez sam nic nie zmienialem :) jakby cos to podaj konfigi ktore Ci potrzebne to wkleje
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2831

PostPosted: Thu Jan 31, 2013 1:17 pm    Post subject: Reply with quote

a ping dziala na smtp.gmail.com? Sprawdz tez uprawnienia

Code:
ls -ld /usr/sbin/ssmtp /etc/ssmtp /etc/ssmtp/ssmtp.conf /etc/resolv.conf

_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
galandilias
n00b
n00b


Joined: 03 Jul 2011
Posts: 47

PostPosted: Thu Jan 31, 2013 1:29 pm    Post subject: Reply with quote

ping dziala :)

uprawnienia mam takie:
Code:
-rw-r--r-- 1 root root    149 Jan 29 17:32 /etc/resolv.conf
drwxr-xr-x 2 root root   4096 Jan 29 17:16 /etc/ssmtp
-rw-r----- 1 root ssmtp  1589 Jan 29 18:20 /etc/ssmtp/ssmtp.conf
-rwx--s--x 1 root ssmtp 39576 Jan 29 17:08 /usr/sbin/ssmtp


zrobilem
Code:
chmod a+r /etc/ssmtp/ssmtp.conf
ale dalej bez zmian
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2831

PostPosted: Thu Jan 31, 2013 1:38 pm    Post subject: Reply with quote

ping z usera apache smiga, czyli to nie dnsy. Ale mimo wszystko zamien smtp.gmail.com na ip 74.125.136.109 lub 74.125.136.108 i sprawdz ponownie.

Dalej, skoro z roota dzialal to propnowal bym wrzucic strace i dac:

Code:
echo -e 'Subject: testowy mail\n\nBodywiadomosci' | strace sendmail TWOJ_ADRES@DOMENA 2>&1 | tee user.log
i analogicznie, zrobic to na roocie i na userze a potem sprawdzac, ktore liniji sa rozne.
_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
galandilias
n00b
n00b


Joined: 03 Jul 2011
Posts: 47

PostPosted: Thu Jan 31, 2013 1:47 pm    Post subject: Reply with quote

pingi na IPki chodza

logi z Twojej komendy znajdziesz tu:
http://nowakmarcin.com/logs/
widze roznice ale mi to nie mowi za wiele :/
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2831

PostPosted: Thu Jan 31, 2013 3:00 pm    Post subject: Reply with quote

nie mam pomyslu, wlacz debug w ssmtp.conf i zobacz w sysloga jakiego tam masz co on mowi.
_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
galandilias
n00b
n00b


Joined: 03 Jul 2011
Posts: 47

PostPosted: Thu Jan 31, 2013 3:21 pm    Post subject: Reply with quote

logi juz zbieram :) oto one:

Proba dla apache:

Code:
Jan 31 14:41:53 mnet-proliant su[8729]: Successful su for apache by root
Jan 31 14:41:53 mnet-proliant su[8729]: + /dev/pts/0 root:apache
Jan 31 14:41:53 mnet-proliant su[8729]: pam_unix(su:session): session opened for user apache by root(uid=0)
Jan 31 14:42:01 mnet-proliant sSMTP[8736]: Creating SSL connection to host
Jan 31 14:42:01 mnet-proliant sSMTP[8736]: 220 mx.google.com ESMTP j46sm4104282eeo.3 - gsmtp
Jan 31 14:42:01 mnet-proliant sSMTP[8736]: EHLO nowakmarcin.com
Jan 31 14:42:01 mnet-proliant sSMTP[8736]: 250 ENHANCEDSTATUSCODES
Jan 31 14:42:01 mnet-proliant sSMTP[8736]: STARTTLS
Jan 31 14:42:01 mnet-proliant sSMTP[8736]: 220 2.0.0 Ready to start TLS
Jan 31 14:42:01 mnet-proliant sSMTP[8736]: Cannot open smtp.gmail.com:587


Proba na root:

Code:
Jan 31 14:42:07 mnet-proliant su[8729]: pam_unix(su:session): session closed for user apache
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: Set MailHub="smtp.gmail.com"
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: via SMTP Port Number="587"
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: Creating SSL connection to host
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: 220 mx.google.com ESMTP o3sm7452211eem.15 - gsmtp
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: EHLO nowakmarcin.com
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: 250 ENHANCEDSTATUSCODES
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: STARTTLS
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: 220 2.0.0 Ready to start TLS
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: SSL connection using ECDHE-RSA-RC4-SHA
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: EHLO nowakmarcin.com
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: 250 ENHANCEDSTATUSCODES
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: AUTH LOGIN
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: 334 VXNlcm5hbWU6
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: cG9zdG1hbkBub3dha21hcmNpbi5jb20=
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: 334 UGFzc3dvcmQ6
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: OVI0VmFtYXM=
Jan 31 14:42:38 mnet-proliant sSMTP[8757]: 235 2.7.0 Accepted
Jan 31 14:42:38 mnet-proliant sSMTP[8757]: MAIL FROM:<xxxxxxxx@nowakmarcin.com>
Jan 31 14:42:38 mnet-proliant sSMTP[8757]: 250 2.1.0 OK o3sm7452211eem.15 - gsmtp
Jan 31 14:42:38 mnet-proliant sSMTP[8757]: RCPT TO:<xxxxxxxx@gmail.com>
Jan 31 14:42:38 mnet-proliant sSMTP[8757]: 250 2.1.5 OK o3sm7452211eem.15 - gsmtp
Jan 31 14:42:38 mnet-proliant sSMTP[8757]: DATA
Jan 31 14:42:39 mnet-proliant sSMTP[8757]: 354  Go ahead o3sm7452211eem.15 - gsmtp
Jan 31 14:42:39 mnet-proliant sSMTP[8757]: Received: by nowakmarcin.com (sSMTP sendmail emulation); Thu, 31 Jan 2013 14:42:37 +0100
Jan 31 14:42:39 mnet-proliant sSMTP[8757]: From: "root" <xxxxxxxx@nowakmarcin.com>
Jan 31 14:42:39 mnet-proliant sSMTP[8757]: Date: Thu, 31 Jan 2013 14:42:37 +0100
Jan 31 14:42:39 mnet-proliant sSMTP[8757]: Subject: testowy mail
Jan 31 14:42:39 mnet-proliant sSMTP[8757]:
Jan 31 14:42:39 mnet-proliant sSMTP[8757]: Bodywiadomosci
Jan 31 14:42:40 mnet-proliant sSMTP[8757]: .
Jan 31 14:42:41 mnet-proliant sSMTP[8757]: 250 2.0.0 OK 1359639761 o3sm7452211eem.15 - gsmtp
Jan 31 14:42:41 mnet-proliant sSMTP[8757]: QUIT
Jan 31 14:42:41 mnet-proliant sSMTP[8757]: 221 2.0.0 closing connection o3sm7452211eem.15 - gsmtp
Jan 31 14:42:41 mnet-proliant sSMTP[8757]: Sent mail for xxxxxxxx@nowakmarcin.com (221 2.0.0 closing connection o3sm7452211eem.15 - gsmtp) uid=0 username=root outbytes=377
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2831

PostPosted: Thu Jan 31, 2013 4:11 pm    Post subject: Reply with quote

A wez stworz usera typo 'asd' z grupa glowna users i z niego przetestuj.
Code:
useradd -m -g users asd


pokaz tez z jakimi flagami kompilowales ssmtp (use i cflags).
_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
galandilias
n00b
n00b


Joined: 03 Jul 2011
Posts: 47

PostPosted: Thu Jan 31, 2013 4:43 pm    Post subject: Reply with quote

z asd tez nie idzie... :/

[ebuild R ] mail-mta/ssmtp-2.64-r2 USE="ipv6 mta ssl -gnutls" 0 kB

tak sie buduje ssmtp
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2831

PostPosted: Thu Jan 31, 2013 6:56 pm    Post subject: Reply with quote

Sprawdz z gnutls. Wydaje mi sie, ze bez tego nie powinno w ogole SSL dzialac tam.
_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
galandilias
n00b
n00b


Joined: 03 Jul 2011
Posts: 47

PostPosted: Fri Feb 01, 2013 2:46 pm    Post subject: Reply with quote

No - skompilowalem i patrz Pan :P

Code:
Feb  1 15:44:46 mnet-proliant kernel: sendmail[32256]: segfault at 8 ip 00007fd56e4b4471 sp 00007fff042cad88 error 4 in libc-2.15.so[7fd56e42f000+1a5000]


to lepiej czy gorzej? :)

z root-a dalej dziala
Back to top
View user's profile Send private message
Jacekalex
Guru
Guru


Joined: 17 Sep 2009
Posts: 493

PostPosted: Fri Feb 01, 2013 6:47 pm    Post subject: Reply with quote

Spróbuj użyć zamiast ssmtp, mail-mta/esmtp, u mnie z gmailem działał jeszcze niedawno (obecnie mam Posfixa), całość konfiguracji ustawia się w /etc/esmtprc, kompilacja na kompilatorze gcc-4.6.3 hardened, grsec i pax (mprotect i noexec) w jaju też nie stanowiły problemu.

Code:
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: AUTH LOGIN
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: 334 xxxxxxxxxxxxxxxxxx
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: xxxxxxxxxxxxxxxxxxxxxx
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: 334 xxxxxxxxxxxxxxxx
Jan 31 14:42:37 mnet-proliant sSMTP[8757]: xxxxxxxxxxxx=

I wyczyść dane logowania z twojego logu oraz zmień hasło do konta na gmailu, przecież z AUTH-LOGIN może odkodować każdy. :twisted:

Edit:
Jeśli wysyłasz z TLS (gmail nie pozwoli na autoryzację bez ssl/tls), to lepiej puść pocztę przez port 465/smtps z ssl.
Szybciej to działa, bo najpierw jest nawiązywane połączenie ssl, a dopiero potem zaczyna się dialog smtp, nie trzeba osobno wołać o starttls.

Jak coś nie działa z smtp, to radzę najpierw przetestować połączenie programem net-mail/swaks, ten najlepiej diagnozuje połączenia smtp.

Pozdrawiam
8)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum