Envoyer un mail via smtp.orange.fr (dans page PHP)

Adrien.D Membre non connecté
-
- Voir le profil du membre Adrien.D
- Inscrit le : 30/05/2011
- Site internet
- Groupes :
J'ai un serveur WAMP sur ma machine, et un serveur LAMP sur mon serveur.
WAMP me sert a tester mes pages, LAMP à mettre en ligne mon site.
Or, il y a une petite chose qui marche sur WAMP mais pas sur LAMP:
Je tente via la fonction mail() de PHP d'envoyer un mail.
Mon abonnement à la maison étant orange, je passe par les smtp d'orange.
Il faut pour cela modifier un paramètre dans le php.ini:
/etc/php.ini :
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.orange.fr
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.orange.fr
; http://php.net/smtp-port
smtp_port = 25
Sous WAMP, ça marche et pas sur LAMP (en effet, il y a la mention For Win32 Only)
Comment je peux faire sur LAMP ?
Merci

Config : PC Fixe : X470 GAMING PRO- AMD Ryzen 5 2600X - 16Go RAM - Radeon RX 560 (Pilote libre) - Gentoo Linux - GNOME Desktop - Kernel 5.10 LTS
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !


pamputt Membre non connecté
-
- Voir le profil du membre pamputt
- Inscrit le : 03/01/2010
- Groupes :

Adrien.D Membre non connecté
-
- Voir le profil du membre Adrien.D
- Inscrit le : 30/05/2011
- Site internet
- Groupes :
j'essaie ce soir dès mon retour.
Config : PC Fixe : X470 GAMING PRO- AMD Ryzen 5 2600X - 16Go RAM - Radeon RX 560 (Pilote libre) - Gentoo Linux - GNOME Desktop - Kernel 5.10 LTS
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !


Adrien.D Membre non connecté
-
- Voir le profil du membre Adrien.D
- Inscrit le : 30/05/2011
- Site internet
- Groupes :
non en fait, je n'ai rien compris .... et ça ne marche pas.
Caché :
24 [SERVER] [20:56:01] root@valiona: /var/www/html # cat /etc/postfix/main.cf
# This file contains only the parameters changed from a default install
# see /etc/postfix/main.cf.dist for a commented, fuller version of this file.
# These are changed by postfix install script
readme_directory = /usr/share/doc/postfix/README_FILES
html_directory = /usr/share/doc/postfix/html
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
command_directory = /usr/sbin
manpage_directory = /usr/share/man
daemon_directory = /usr/lib/postfix
data_directory = /var/lib/postfix
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
queue_directory = /var/spool/postfix
mail_owner = postfix
# User configurable parameters
inet_interfaces = localhost
inet_protocols = all
mynetworks_style = host
#delay_warning_time = 4h
smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) (Mageia Linux)
unknown_local_recipient_reject_code = 450
smtp-filter_destination_concurrency_limit = 2
lmtp-filter_destination_concurrency_limit = 2
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem
smtpd_tls_key_file = /etc/pki/tls/private/postfix.pem
smtpd_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
relayhost = [smtp.orange.fr]
# This file contains only the parameters changed from a default install
# see /etc/postfix/main.cf.dist for a commented, fuller version of this file.
# These are changed by postfix install script
readme_directory = /usr/share/doc/postfix/README_FILES
html_directory = /usr/share/doc/postfix/html
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
command_directory = /usr/sbin
manpage_directory = /usr/share/man
daemon_directory = /usr/lib/postfix
data_directory = /var/lib/postfix
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
queue_directory = /var/spool/postfix
mail_owner = postfix
# User configurable parameters
inet_interfaces = localhost
inet_protocols = all
mynetworks_style = host
#delay_warning_time = 4h
smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) (Mageia Linux)
unknown_local_recipient_reject_code = 450
smtp-filter_destination_concurrency_limit = 2
lmtp-filter_destination_concurrency_limit = 2
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem
smtpd_tls_key_file = /etc/pki/tls/private/postfix.pem
smtpd_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
relayhost = [smtp.orange.fr]
Code TEXT :
25 [SERVER] [20:56:29] root@valiona: /var/www/html # grep sendmail /etc/php.ini ; http://php.net/sendmail-from ;sendmail_from = me@example.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = /usr/sbin/sendmail ; to the sendmail binary. These parameters will always replace the value of
Config : PC Fixe : X470 GAMING PRO- AMD Ryzen 5 2600X - 16Go RAM - Radeon RX 560 (Pilote libre) - Gentoo Linux - GNOME Desktop - Kernel 5.10 LTS
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !


AgentSteel Membre non connecté
-
- Voir le profil du membre AgentSteel
- Inscrit le : 10/07/2011
- Site internet
Pour la conf de Postfix, je ne pense pas qu'il faille encadrer ton relayhost par des [ ]
donc
relayhost = smtp.orange.fr
devrait suffire.
Penser à redémarrer postfix
# service postfix restart
Pour tester l'envoi d'un mail, toujours dans un terminal
(installer le paquet qui contient la commande "mail")
# urpmi nail
puis
# echo "mon message" | mail -s "sujet" moi@monmail.com
Et regarder les logs de postfix pour voir si ça passe bien
# tail /var/log/mail/info.log

Adrien.D Membre non connecté
-
- Voir le profil du membre Adrien.D
- Inscrit le : 30/05/2011
- Site internet
- Groupes :
J'ai enlevé les crochets mais cela ne fonctionne pas:
Caché :
1 [SERVER] [08:51:28] adrien@valiona: ~ $ su
Mot de passe :
1 [SERVER] [08:51:32] root@valiona: ~ # nano /etc/postfix/main.cf
2 [SERVER] [08:51:56] root@valiona: ~ # service postfix restart
Restarting postfix (via systemctl): [ OK ]
3 [SERVER] [08:52:04] root@valiona: ~ # mai
mail mailfax.sh-sendmail mailstat
mailfax.sh-postfix mailfax.sh-smail mailx
mailfax.sh-qmail mailq
3 [SERVER] [08:52:04] root@valiona: ~ # echo "test" | mail -s "sujet" xxxxx@gmail.com
4 [SERVER] [08:52:33] root@valiona: ~ # send-mail: warning: inet_protocols: IPv6 support is disabled: Address family not supported by protocol
send-mail: warning: inet_protocols: configuring for IPv4 support only
postdrop: warning: inet_protocols: IPv6 support is disabled: Address family not supported by protocol
postdrop: warning: inet_protocols: configuring for IPv4 support only
4 [SERVER] [08:52:43] root@valiona: ~ # tail /var/log/mail/info.log
Aug 11 08:52:33 valiona postfix/pickup[23732]: 8DFD447170: uid=0 from=<root>
Aug 11 08:52:33 valiona postfix/cleanup[23761]: 8DFD447170: message-id=<20120811 065233.8DFD447170@valiona.localdomain>
Aug 11 08:52:33 valiona postfix/qmgr[23733]: 8DFD447170: from=<root@valiona.localdomain>, size=446, nrcpt=1 (queue active)
Aug 11 08:52:35 valiona postfix/smtp[23769]: 8DFD447170: to=<xxxxxxxx@gmail.com>, relay=smtp.orange.fr[193.252.22.86]:25, delay=1.5,
delays=0.13/0.08/0.25/1.1, dsn=5.1.0, status=bounced (host smtp.orange.fr[193.252.22.86] said: 550 5.1.0 Authentification requise. Authentication Required. OFR102_402 [402] (inreply to MAIL FROM command))
Aug 11 08:52:35 valiona postfix/cleanup[23761]: 269ED471BA: message-id=<20120811065235.269ED471BA@valiona.localdomain>
Aug 11 08:52:35 valiona postfix/qmgr[23733]: 269ED471BA: from=<>, size=2456, nrcpt=1 (queue active)
Aug 11 08:52:35 valiona postfix/bounce[23773]: 8DFD447170: sender non-delivery notification: 269ED471BA
Aug 11 08:52:35 valiona postfix/qmgr[23733]: 8DFD447170: removed
Aug 11 08:52:35 valiona postfix/local[23777]: 269ED471BA: to=<postfix@valiona.localdomain>, orig_to=<root@valiona.localdomain>, relay=local, delay=0.17, delays=0.06/0.02/0/0.09, dsn=5.2.2, status=bounced (cannot update mailbox /var/mail/postfix for user postfix. error writing message: File too large)
Aug 11 08:52:35 valiona postfix/qmgr[23733]: 269ED471BA: removed
5 [SERVER] [08:52:52] root@valiona: ~ #
Mot de passe :
1 [SERVER] [08:51:32] root@valiona: ~ # nano /etc/postfix/main.cf
2 [SERVER] [08:51:56] root@valiona: ~ # service postfix restart
Restarting postfix (via systemctl): [ OK ]
3 [SERVER] [08:52:04] root@valiona: ~ # mai
mail mailfax.sh-sendmail mailstat
mailfax.sh-postfix mailfax.sh-smail mailx
mailfax.sh-qmail mailq
3 [SERVER] [08:52:04] root@valiona: ~ # echo "test" | mail -s "sujet" xxxxx@gmail.com
4 [SERVER] [08:52:33] root@valiona: ~ # send-mail: warning: inet_protocols: IPv6 support is disabled: Address family not supported by protocol
send-mail: warning: inet_protocols: configuring for IPv4 support only
postdrop: warning: inet_protocols: IPv6 support is disabled: Address family not supported by protocol
postdrop: warning: inet_protocols: configuring for IPv4 support only
4 [SERVER] [08:52:43] root@valiona: ~ # tail /var/log/mail/info.log
Aug 11 08:52:33 valiona postfix/pickup[23732]: 8DFD447170: uid=0 from=<root>
Aug 11 08:52:33 valiona postfix/cleanup[23761]: 8DFD447170: message-id=<20120811 065233.8DFD447170@valiona.localdomain>
Aug 11 08:52:33 valiona postfix/qmgr[23733]: 8DFD447170: from=<root@valiona.localdomain>, size=446, nrcpt=1 (queue active)
Aug 11 08:52:35 valiona postfix/smtp[23769]: 8DFD447170: to=<xxxxxxxx@gmail.com>, relay=smtp.orange.fr[193.252.22.86]:25, delay=1.5,
delays=0.13/0.08/0.25/1.1, dsn=5.1.0, status=bounced (host smtp.orange.fr[193.252.22.86] said: 550 5.1.0 Authentification requise. Authentication Required. OFR102_402 [402] (inreply to MAIL FROM command))
Aug 11 08:52:35 valiona postfix/cleanup[23761]: 269ED471BA: message-id=<20120811065235.269ED471BA@valiona.localdomain>
Aug 11 08:52:35 valiona postfix/qmgr[23733]: 269ED471BA: from=<>, size=2456, nrcpt=1 (queue active)
Aug 11 08:52:35 valiona postfix/bounce[23773]: 8DFD447170: sender non-delivery notification: 269ED471BA
Aug 11 08:52:35 valiona postfix/qmgr[23733]: 8DFD447170: removed
Aug 11 08:52:35 valiona postfix/local[23777]: 269ED471BA: to=<postfix@valiona.localdomain>, orig_to=<root@valiona.localdomain>, relay=local, delay=0.17, delays=0.06/0.02/0/0.09, dsn=5.2.2, status=bounced (cannot update mailbox /var/mail/postfix for user postfix. error writing message: File too large)
Aug 11 08:52:35 valiona postfix/qmgr[23733]: 269ED471BA: removed
5 [SERVER] [08:52:52] root@valiona: ~ #
C'est comme s'il y avait besoin d'une authentification ...
Édité par Adrien.D Le 11/08/2012 à 08h57
Config : PC Fixe : X470 GAMING PRO- AMD Ryzen 5 2600X - 16Go RAM - Radeon RX 560 (Pilote libre) - Gentoo Linux - GNOME Desktop - Kernel 5.10 LTS
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !


AgentSteel Membre non connecté
-
- Voir le profil du membre AgentSteel
- Inscrit le : 10/07/2011
- Site internet

google m'a chuchoté ce tuto qui devrait t'aider :
http://liberez-le-tux.servhome.org/blog/2010/03/25/installer-un-serveur-smtp-relai-via-postfix/

Adrien.D Membre non connecté
-
- Voir le profil du membre Adrien.D
- Inscrit le : 30/05/2011
- Site internet
- Groupes :
Je vais tenter de regarder de ce côté, j'avais fait quelques essais avec un tuto similaire (Ubuntu) mais le souci c'est que le même PC avec un "WAMP" ne demandait aucune authentification.
Config : PC Fixe : X470 GAMING PRO- AMD Ryzen 5 2600X - 16Go RAM - Radeon RX 560 (Pilote libre) - Gentoo Linux - GNOME Desktop - Kernel 5.10 LTS
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !
Ancien Webmaster de MageiaLinuxOnline. Les remplaçants assurent !


cobe Membre non connecté
-
- Voir le profil du membre cobe
- Inscrit le : 13/01/2015
Je déterre ce sujet car je coince sur la configuration de postfix pour l'envoi de mail depuis LAMP, pour tester le fonctionnement d'un site que je développe en php mysql en local...
J'ai consulté un tas de forums et de la doc, mais je n'arrive pas à saisir le fonctionnement de ce truc ! J'ai cru comprendre qu'il faut modifier le fichier /etc/postfix/main.cf pour y insérer le smtp de l'adresse mail que je veux utiliser pour l'envoi (pour moi ce sera par free) en renseignant un champ "relayhost", mais je ne trouve nulle part ce champ "relayhost" dans main.cf...
Pour info, voici le code de main.cf:
Code TEXT :
# This file contains only the parameters changed from a default install # see /etc/postfix/main.cf.dist for a commented, fuller version of this file. # These are changed by postfix install script readme_directory = /usr/share/doc/postfix/README_FILES html_directory = /usr/share/doc/postfix/html sendmail_path = /usr/sbin/sendmail.postfix setgid_group = postdrop command_directory = /usr/sbin manpage_directory = /usr/share/man daemon_directory = /usr/lib64/postfix data_directory = /var/lib/postfix newaliases_path = /usr/bin/newaliases mailq_path = /usr/bin/mailq queue_directory = /var/spool/postfix mail_owner = postfix # User configurable parameters inet_interfaces = localhost inet_protocols = all mynetworks_style = host #delay_warning_time = 4h smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) (Mageia Linux) unknown_local_recipient_reject_code = 450 smtp-filter_destination_concurrency_limit = 2 lmtp-filter_destination_concurrency_limit = 2 # enable opportunistic TLS when receiving smtpd_use_tls = yes smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem smtpd_tls_key_file = /etc/pki/tls/private/postfix.pem smtpd_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt # enable opportunistic TLS when sending smtp_tls_security_level = may smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
Faut-il ajouter des lignes à ce fichier? lesquelles et à quel endroit? Il y a d'autres choses à installer ou configurer (j'ai vu passer "sendmail" dans mes recherches, mais "urpmi sendmail" me renvoie à la nécessité de désinstaller postfix... ) ?
Si vous aviez une info pour m'aider à sortir de mon ornière...
Merci!

laurent100090 Membre non connecté
-
- Voir le profil du membre laurent100090
- Inscrit le : 04/04/2017
quelqu'un a trouvé une solution?

Tonin Membre non connecté
-
- Voir le profil du membre Tonin
- Inscrit le : 02/07/2013
- Groupes :
Pour ma part ça marche depuis la console, un script php et piwigo (qui utilise phpmailer). Le tout sans sendmail (mais il existe tout de même un /usr/sbin/sendmail, man dit : "sendmail - Postfix to Sendmail compatibility interface").
Quand on écrit son script php, il faut penser à ajouter un paramètre additionnel dans la fonction mail : '-fmonusername'.
Alors pour postfix, voici les documents qui m'avaient rendus service :
- (brisé) http://mdvmondelinux.tuxfamily.org/utiliser-postfix-sous-mandriva
- (brisé) http://webcache.googleusercontent.com/search?q=cache:WLEfskLFC1UJ:mdvmondelinux.tuxfamily.org/utiliser-postfix-sous-mandriva+&cd=1&hl=fr&ct=clnk&gl=fr
- http://postfix.traduc.org/index.php/SASL_README.html#client_sasl
- http://www.cyberciti.biz/tips/howto-postfix-masquerade-change-email-mail-address.html
- http://www.postfix.org/postconf.5.html#smtp_generic_maps
- (brisé) http://www.trustonme.net/didactels/makeprintable.php?elmt=174
Voici la série de commandes que je réalise lors d'une réinstallation :
Code TEXT :
# (root) vim /etc/postfix/main.cf vim /etc/postfix/aliases vim /etc/postfix/generic postmap /etc/postfix/generic systemctl restart postfix.service postconf -n # vim /etc/postfix/sasl_passwd postmap /etc/postfix/sasl_passwd systemctl restart postfix.service $ (normal user : monusername) mail mon.adresse@maboite.fr # Return + Ctrl+d pour envoyer mail mailq
EDIT : Attention, ci-dessous ce sont des extraits de fichiers, et non les configurations complètes. En somme, les changements par rapport à une configuration par défaut.
Avec vim /etc/postfix/main.cf
Code TEXT :
# Usage du port 587 (submission) sans "vérifier" le relay ([]) relayhost = [smtp.maboite.fr]:submission # authentification smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous # Masquerading pour serveur sans enregistrement DNS - MAIL FROM smtp_generic_maps = hash:/etc/postfix/generic
Avec vim /etc/postfix/aliases
Code TEXT :
postmaster: root # Person who should get root's mail. This alias # must exist. # CHANGE THIS LINE to an account of a HUMAN #root: postfix root: monusername
Avec vim /etc/postfix/generic
Code TEXT :
mon.nom-de-domaine.fr doit effectivement correspondre à la machinemonusername@localhost.localdomain mon.adresse@maboite.fr monusername@mon.nom-de-domaine.fr mon.adresse@maboite.fr
sinon le message pourrait être refusé : "Diagnostic-Code: smtp; 550 5.5.0 Emetteur invalide. Invalid Sender."
Avec vim /etc/postfix/sasl_passwd
Code TEXT :
[smtp.maboite.fr]:submission mon.adresse@maboite.fr:***P*W*D***
En souhaitant que ça aide à débloquer la situation
Édité par Tonin Le 06/04/2017 à 00h25
Mageia 9 | > | Mageia 5 - 32bits - LXDE - Compiz ; ... Mandriva ; ... power pack, Mandrake 7.0 |

Papoteur Membre non connecté
-
- Voir le profil du membre Papoteur
- Inscrit le : 03/10/2011
- Groupes :
-
Modérateur
-
Équipe Mageia
-
Administrateur
-
Forgeron
Quelqu'un confirme ?
On en fait une page dans le wiki ?
Yves

laurent100090 Membre non connecté
-
- Voir le profil du membre laurent100090
- Inscrit le : 04/04/2017
Merci Tonin!!!!
#installation de postfix
urpmi postfix
Dans vim /etc/postfix/main.cf
Code TEXT :
# Usage du port 587 ( avec paramètre submission) sans "vérifier" le relay ([]) relayhost = [smtp.maboite.fr]:submission # authentification smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd #refuse connexion anonyme smtp_sasl_security_options = noanonymous #ça je l'ai rajouté : ca permet une connexion sécurisée uniquement smtpd_tls_auth_only = yes
Dans vim /etc/postfix/sasl_passwd
Code TEXT :
[smtp.maboite.fr]:submission mon.adresse@maboite.fr:mot-de-passe
#On exécute les commandes suivantes :
Code :
]
postmap /etc/postfix/sasl_passwd
systemctl restart postfix.service
postconf -n
#test d’envoi d'un message en terminal (en root)
Code :
echo "Mail envoyé le $(date)" | mail -s "Test envoi de mail depuis $(hostname)" mon.adresse-de-destination@maboite-de-destination.fr
Code :
#pour visualiser les messages en attente : (0 si mail bien envoyé)
mailq
#Pour supprimer tous les messages de la queue (si 1 mail est bloqué):
postsuper -d ALL
----------------
Maintenant faut que je vois si un mail peut être envoyé par un daemon activé par un cron ....
Édité par laurent100090 Le 08/04/2017 à 00h22

laurent100090 Membre non connecté
-
- Voir le profil du membre laurent100090
- Inscrit le : 04/04/2017
Bon ben ça marche impecc... on peut faire un cron pour l'envoi de mail ...

Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie