Estoy usando ubuntu 14.04. He instalado postfix usando {sudo apt-get install postfix}. Se instala exitosamente. Ahora estoy intentando enviar correo usando la terminal, descubrí que el correo se envía al destino. Pero cuando lo intento desde /var/www/html/mailsend.php descubrí que el correo no se envía. Este es mi código main.cf:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#@raaj
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
#@raaj
#smtpd_banner = $myhostname ESMTP $mail_name yslserver
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = yslserver
#@raaj
#mydomain = localhost
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
#akk
myhostname = yslserver
mydomain = localhost
myorigin = $mydomain
default_destination_concurrency_limit = 4
soft_bounce = yes
mydestination = $myhostname, rajkhurana, yslserver, localhost.localdomain, ,localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter =
inet_interfaces = all
inet_protocols = all
#@raaj
#mailbox_command = procmail -a "$EXTENSION"
Estoy usando este código:
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['sendmail'])) {
//Email information
$mailFrom = "[email protected]";
$mailTo = $_REQUEST['mailto'];
$subject = $_REQUEST['subject'];
$comment = $_REQUEST['comment'];
//print_r($_POST);
//send email
if (mail($mailTo, "$subject", $comment, "From: " . $mailFrom)){
echo "Thanks, mail has sent successfully";
}
else {
//Email response
echo "Mail could not sent..!";
}
}
//if "email" variable is not filled out, display the form
else { ?>
<html>
<head>
<style>
#main {
width:300px;
height:auto;
background-color:#D5CADA;
padding:10px;
margin:10px;
}
.section {
width:290px;
height:auto;
}
</style>
</head>
<body>
<div id="main">
<form method="post" action="">
<div class="section">
Email To: <input name="mailto" id ="mailto" type="text" /><br />
Subject: <input name="subject" type="text" /><br />
Message:<br />
<textarea name="comment" rows="7" cols="33"></textarea><br />
<div>
<input type="submit" name="sendmail" id="sendmail" value="Submit" />
<input type="reset" name="reset" id="reset" value="Reset"/>
</div>
</div>
</form>
</div>
</body>
</html>
<?php } ?>
Por favor ayúdenme cómo debo resolver el problema.
Respuesta1
Parece un problema de PHP ya que funciona desde la línea de comandos. ¿Ha definido su ruta de envío de correo en su archivo php.ini?
Ver esta publicaciónEnvío de correos con PHP, LAMPP y PostFix