1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Using PHPMailer on Infomaniak
This guide explains how to use PHPMailer with the Web hosting.
Introduction
- PHPMailer is a library that allows sending HTML-formatted emails from a website.
- It notably handles attachments, and supports SMTP authentication and multipart/alternative for clients who cannot read HTML-formatted emails.
Using PHPMailer
To use PHPMailer, it is necessary to install it manually:
- Click here to download the PHPMailer library.
- Copy the files into a directory of your website via FTP.
Link your script to PHPMailer, example:
require_once('chemin_a_modifier/class.phpmailer.php');
Fixing a Sender mismatch error
In the SMTP (Simple Mail Transfer Protocol) protocol, the From header specifies the email address of the message sender. This is the address that will appear in the βFromβ field of the message received by the recipient.
In PHPMailer, the method setFrom is used to set the sender's email address, while the header From is used to specify this same address when sending the message. The method setFrom also sets the Reply-To field of the email.
The error Sender mismatch SMTP code: 550 Additional SMTP info: 5.7.1 occurs when the email address specified in the setFrom field does not match the email address specified in the From header when sending the message.
To avoid this error:
Instead of using the
setFrommethod to set the sender's email address, use theFromproperty of the PHPMailer object, example:$mail = new PHPMailer(); $mail->From = 'expediteur@domain.xyz';Make sure the value specified in the
Fromproperty exactly matches the email address used in thesetFromfield.Example, if you use
setFromwith a sender name like this:$mail->setFrom('expediteur@domain.xyz', 'Nom Expediteur');β¦ then make sure that the value of
Fromis also set with the sender's name:$mail->From = 'expediteur@domain.xyz'; $mail->FromName = 'Nom Expediteur';
Then, continue with the configuration and sending of the email as usual.