2013-06-15

Bonjour.

J'ai un mutualisé et j'essai d'envoyer un mail en utilisant phpMailer

Mon code:

Code PHP :
---------
public static function sendMail($params){
$ini = unserialize(INI);

$defaults = array(
'SMTPDebug' => $ini['mail']['SMTPDebug'],
'Debugoutput' => $ini['mail']['Debugoutput'],
'Host' => $ini['mail']['Host'],
'Port' => $ini['mail']['Port'],
'SMTPSecure' => $ini['mail']['SMTPSecure'],
'SMTPAuth' => $ini['mail']['SMTPAuth'],
'Username' => $ini['mail']['Username'],
'Password' => $ini['mail']['Password'],
'From' => array($ini['mail']['Username'],$ini['application']['name']),
'Subject' => $ini['application']['name'],
'To' => array(),
'Attachement' => array(),
'Layout' => 'src/main/views/layouts/mail.php',
'Content' => ''

);

$params = array_merge($defaults, $params);

//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->IsSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = $params['SMTPDebug'];
//Ask for HTML-friendly debug output
$mail->Debugoutput = $params['Debugoutput'];
//Set the hostname of the mail server
$mail->Host = $params['Host'];
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = $params['Port'];
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = $params['SMTPSecure'];
//Whether to use SMTP authentication
$mail->SMTPAuth = $params['SMTPAuth'];
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = $params['Username'];
//Password to use for SMTP authentication
$mail->Password = $params['Password'];
//Set who the message is to be sent from
$mail->SetFrom($params['From'][0], $params['From'][1]);

foreach($params['To'] as $to){
//Set who the message is to be sent to
$mail->AddAddress($to[0], $to[1]);
}

//Set the subject line
$mail->Subject = $params['Subject'];

//Read an HTML message body from an external file, convert referenced images to embedded, convert HTML into a basic plain-text alternative body

$mailLayout = file_get_contents($params['Layout']);
$mailContent = str_replace("%content%", $params['Content'], $mailLayout);
$mail->MsgHTML($mailContent, dirname(__FILE__));

//Attach an image file
foreach ($params['Attachement'] as $key => $value) {
$mail->AddAttachment($value);
}

//Send the message, check for errors

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

}
---------
et les config dans mon fichier ini

Code :
---------
;Phpmailer
[mail]
;debug(0=>prod,1=>user,2=>user and server)
SMTPDebug = 2
Debugoutput = "html"
Host = "smtp.mondom.fr"
Port = 25
SMTPSecure = "tls"
SMTPAuth = true
Username = "test@mondom.fr"
Password = "xxxx"
---------
je suis sur des valeurs pour Unername et Password ainsi que pour le Host

Je suis donc en local, j'ai ouvert le port 25 de ma box je ne sais pas si c'est utile

et j'ai donc l'erreur suivante

SMTP -> ERROR: Failed to connect to server: Operation timed out (60)
SMTP Connect() failed.
Mailer Error: SMTP Connect() failed.

J'ai regardé les forums, la seule réponse que j'ai trouvé est d'utiliser QMAIL mais je ne voudrai le faire en smtp.
Toutefois j'ai essayé avec QMAIL, $mail->Send() retourne true mais je ne reçois aucun mail il y a t'il un log mail sur les mutualisés ?

Merci

Show more