1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Using PHPMailer on Infomaniak
This guide explains how to use PHPMailer with Infomaniak Web Hosting.
Preamble
- PHPMailer is a library that allows sending HTML-formatted emails from a website.
- It supports attachments, SMTP authentication, and multipart/alternative for clients that cannot read HTML-formatted emails.
Using PHPMailer
To use PHPMailer, you need to install it manually:
- Click here to download the PHPMailer library.
- Copy the files to a directory on your website via FTP.
Link your script to PHPMailer, example:
require_once('chemin_a_modifier/class.phpmailer.php');
Resolve a Sender mismatch error
In the SMTP (Simple Mail Transfer Protocol) protocol, the From header specifies the sender's email address of the message. This is the address that will appear in the 'From' field of the message received by the recipient.
In PHPMailer, the setFrom method is used to set the sender's email address, while the From header is used to specify this same address when sending the message. The setFrom method 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's name like this:$mail->setFrom('expediteur@domain.xyz', 'Nom Expediteur');β¦ then make sure the value of
Fromis also set with the sender's name:$mail->From = 'expediteur@domain.xyz'; $mail->FromName = 'Nom Expediteur';
Then, continue the email configuration and sending as usual.