OVH Community, votre nouvel espace communautaire.

Release 3 - Fonction mail de php n'envoie pas de mail


cassiopee
19/05/2016, 12h24
A priori, il s'agit juste de bien paramétrer l'appel à la fonction PHP mail().

Cf la doc :

http://php.net/manual/fr/function.mail.php

En particulier l'exemple n°2 qui montre comment ajouter l'entête "From:" à son message.

Ceci dit, la fonction mail() de PHP n'est pas l'idéal de nos jours. De nombreux destinataires de mail (type Yahoo, Gmail.com, etc.)
feront des vérifications du format du message et il ne sera pas évident de passer sous ces fourches caudines
(par exemple pour inclure une ou des pièces jointes). Souvent on va préférer utiliser des librairies toutes faites
type PhpMailer ( https://github.com/PHPMailer/PHPMailer ).

flashgames
19/05/2016, 12h12
Bonjour,

As tu trouvé à tout hsard une solution ?
Je suis preneur.

A+

ericm2006
20/11/2015, 19h37
Bonjour à tous,

Je n'arrive pas à utiliser la fonction mail de php.

Il semblerait que c'est lié au FROM de postfix mais j'arrive pas (ou ne sais pas) à le changer.

Le maillog
Code:
Nov 20 19:19:54 nsXXXX postfix/pickup[28709]: E044F9D895: uid=502 from=
Nov 20 19:19:54 nsXXXX postfix/cleanup[28957]: E044F9D895: message-id=<5d1e80fca084774863de4e37560f3e9d@www.admineeeeeee.ch>
Nov 20 19:19:54 nsXXXX opendkim[28613]: E044F9D895: DKIM-Signature field added (s=default, d=admineeeeeee.ch)
Nov 20 19:19:55 nsXXXX postfix/qmgr[28710]: E044F9D895: from=, size=1107, nrcpt=1 (queue active)
Nov 20 19:19:55 nsXXXX postfix/smtp[28968]: E044F9D895: to=, relay=smtp.yopmail.com[87.98.164.155]:25, delay=0.2, delays=0.15/0.04/0.02/0, dsn=5.0.0, status=bounced (host smtp.yopmail.com[87.98.164.155] said: 501 Syntax: MAIL FROM: 
(in reply to MAIL FROM command)) Nov 20 19:19:55 nsXXXX postfix/cleanup[28957]: 1BE2F9D897: message-id=<20151120181955.1BE2F9D897@nsXXXX.ip-37-187-127.eu> Nov 20 19:19:55 nsXXXX postfix/bounce[28969]: E044F9D895: sender non-delivery notification: 1BE2F9D897 Nov 20 19:19:55 nsXXXX postfix/qmgr[28710]: 1BE2F9D897: from=<>, size=3497, nrcpt=1 (queue active) Nov 20 19:19:55 nsXXXX postfix/trivial-rewrite[28958]: warning: do not list domain nsXXXX.ip-37-187-127.eu in BOTH mydestination and virtual_mailbox_domains Nov 20 19:19:55 nsXXXX postfix/qmgr[28710]: E044F9D895: removed Nov 20 19:19:55 nsXXXX dovecot: lda(admineeeeeee): sieve: msgid=<20151120181955.1BE2F9D897@nsXXXX.ip-37-187-127.eu>: stored mail into mailbox 'INBOX' Nov 20 19:19:55 nsXXXX dovecot: dict: mysql: Connected to localhost (mail) Nov 20 19:19:55 nsXXXX postfix/local[28970]: 1BE2F9D897: to=, orig_to=, relay=local, delay=0.27, delays=0.02/0.03/0/0.22, dsn=2.0.0, status=sent (delivered to command: /usr/libexec/dovecot/deliver) Nov 20 19:19:55 nsXXXX postfix/qmgr[28710]: 1BE2F9D897: removed

Mon postfix 2.6.6:
Code:
command_directory = /usr/sbin

daemon_directory = /usr/libexec/postfix


data_directory = /var/lib/postfix




myhostname = nsXXXX.ip-37-187-127.eu


# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration
# parameters.
#
mydomain = localdomain

# SENDING MAIL
# 
# The myorigin parameter specifies the domain that locally-posted
# mail appears to come from. The default is to append $myhostname,
# which is fine for small sites.  If you run a domain with multiple
# machines, you should (1) change this to $mydomain and (2) set up
# a domain-wide alias database that aliases each user to
# user@that.users.mailhost.
#
# For the sake of consistency between sender and recipient addresses,
# myorigin also specifies the default domain name that is appended
# to recipient addresses that have no @domain part.
#
#myorigin = $myhostname
myorigin = $mydomain

# RECEIVING MAIL

# The inet_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on.  By default,
# the software claims all active interfaces on the machine. The
# parameter also controls delivery of mail to user@[ip.address].
#
# See also the proxy_interfaces parameter, for network addresses that
# are forwarded to us via a proxy or network address translator.
#
# Note: you need to stop/start Postfix when this parameter changes.
#
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
#inet_interfaces = localhost

# Enable IPv4, and IPv6 if supported
inet_protocols = ipv4

# The proxy_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on by way of a
# proxy or network address translation unit. This setting extends
# the address list specified with the inet_interfaces parameter.
#
# You must specify your proxy/NAT addresses when your system is a
# backup MX host for other domains, otherwise mail delivery loops
# will happen when the primary MX host is down.
#
#proxy_interfaces =
#proxy_interfaces = 1.2.3.4

# The mydestination parameter specifies the list of domains that this
# machine considers itself the final destination for.
#
# These domains are routed to the delivery agent specified with the
# local_transport parameter setting. By default, that is the UNIX
# compatible delivery agent that lookups all recipients in /etc/passwd
# and /etc/aliases or their equivalent.
#
# The default is $myhostname + localhost.$mydomain.  On a mail domain
# gateway, you should also include $mydomain.
#
# Do not specify the names of virtual domains - those domains are
# specified elsewhere (see VIRTUAL_README).
#
# Do not specify the names of domains that this machine is backup MX
# host for. Specify those names via the relay_domains settings for
# the SMTP server, or use permit_mx_backup if you are lazy (see
# STANDARD_CONFIGURATION_README).
#
# The local machine is always the final destination for mail addressed
# to user@[the.net.work.address] of an interface that the mail system
# receives mail on (see the inet_interfaces parameter).
#
# Specify a list of host or domain names, /file/name or type:table
# patterns, separated by commas and/or whitespace. A /file/name
# pattern is replaced by its contents; a type:table is matched when
# a name matches a lookup key (the right-hand side is ignored).
# Continue long lines by starting the next line with whitespace.
#
# See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS".
#
mydestination = localhost.$mydomain, localhost, localhost.localdomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
#	mail.$mydomain, www.$mydomain, ftp.$mydomain

# REJECTING MAIL FOR UNKNOWN LOCAL USERS
#
# The local_recipient_maps parameter specifies optional lookup tables
# with all names or addresses of users that are local with respect
# to $mydestination, $inet_interfaces or $proxy_interfaces.
#
# If this parameter is defined, then the SMTP server will reject
# mail for unknown local users. This parameter is defined by default.
#
# To turn off local recipient checking in the SMTP server, specify
# local_recipient_maps = (i.e. empty).
#
# The default setting assumes that you use the default Postfix local
# delivery agent for local delivery. You need to update the
# local_recipient_maps setting if:
#
# - You define $mydestination domain recipients in files other than
#   /etc/passwd, /etc/aliases, or the $virtual_alias_maps files.
#   For example, you define $mydestination domain recipients in    
#   the $virtual_mailbox_maps files.
#
# - You redefine the local delivery agent in master.cf.
#
# - You redefine the "local_transport" setting in main.cf.
#
# - You use the "luser_relay", "mailbox_transport", or "fallback_transport"
#   feature of the Postfix local delivery agent (see local(8)).
#
# Details are described in the LOCAL_RECIPIENT_README file.
#
# Beware: if the Postfix SMTP server runs chrooted, you probably have
# to access the passwd file via the proxymap service, in order to
# overcome chroot restrictions. The alternative, having a copy of
# the system passwd file in the chroot jail is just not practical.
#
# The right-hand side of the lookup tables is conveniently ignored.
# In the left-hand side, specify a bare username, an @domain.tld
# wild-card, or specify a user@domain.tld address.
# 
#local_recipient_maps = unix:passwd.byname $alias_maps
#local_recipient_maps = proxy:unix:passwd.byname $alias_maps
local_recipient_maps = unix:passwd.byname

# The unknown_local_recipient_reject_code specifies the SMTP server
# response code when a recipient domain matches $mydestination or
# ${proxy,inet}_interfaces, while $local_recipient_maps is non-empty
# and the recipient address or address local-part is not found.
#
# The default setting is 550 (reject mail) but it is safer to start
# with 450 (try again later) until you are certain that your
# local_recipient_maps settings are OK.
#
unknown_local_recipient_reject_code = 550

# TRUST AND RELAY CONTROL
mynetworks = 127.0.0.0/8

alias_maps = hash:/etc/aliases, hash:/etc/mailman/aliases

alias_database = hash:/etc/aliases, hash:/etc/mailman/aliases

recipient_delimiter = +

local_destination_concurrency_limit = 2



debug_peer_level = 2




debugger_command =
	 PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
	 ddd $daemon_directory/$process_name $process_id & sleep 5



sendmail_path = /usr/sbin/sendmail.postfix


newaliases_path = /usr/bin/newaliases.postfix


mailq_path = /usr/bin/mailq.postfix


setgid_group = postdrop


html_directory = no


manpage_directory = /usr/share/man

sample_directory = /usr/share/doc/postfix-2.6.6/samples

# readme_directory: The location of the Postfix README files.
#
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES


smtpd_recipient_restrictions=check_recipient_access mysql:/etc/postfix/sql/mysql_amavis_in.cf, permit_mynetworks, reject_unauth_destination 
external_submission_restrictions=check_recipient_access mysql:/etc/postfix/sql/mysql_amavis_in.cf, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination

virtual_mailbox_domains = mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
virtual_alias_maps = mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_mailing.cf
virtual_mailbox_base = /var/mail/vhosts
virtual_uid_maps = static:500
virtual_gid_maps = static:101
virtual_transport = dovecot

virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/sql/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
virtual_overquota_bounce = yes
transport_maps = hash:/etc/postfix/transport
#
# translate sender root to postmaster@nsXXXX.ip-37-187-127.eu

#
sender_canonical_maps=hash:/etc/postfix/sender_canonical

#
#  multiple recipients (to dovecot) in one mail won't work if not activated!
#
dovecot_destination_recipient_limit = 1

#
# OpenDKIM
#
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
milter_default_action = accept

# TLS
smtpd_tls_security_level = may
smtpd_tls_key_file = /etc/pki/tls/private/localhost.key
smtpd_tls_cert_file = /etc/pki/tls/certs/localhost.crt
smtpd_tls_loglevel = 1
smtpd_tls_session_cache_timeout = 3600s
smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_tls_cache.db
smtpd_tls_auth_only = yes
tls_random_source = dev:/dev/urandom

# dovecot
mailbox_command = /usr/libexec/dovecot/deliver
Merci d'avance