1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Use PHPMailer on Infomaniak
This guide explains how to use PHPMailer with the Web hosting Infomaniak.
Preamble
- PHPMailer is a library for sending e-mails from a website in HTML format.
- The latter allows for the support of attachments, and the support of SMTP authentication and multipart/alternative for customers who cannot read emails in HTML format.
Use PHPMailer
To use PHPMailer, it is necessary to install it manually:
- Click here in order to download the PHPMailer library.
- Copy files to a directory of your website by FTP.
Link your script to PHPMailer, example:
require_once('chemin_a_modifier/class.phpmailer.php');
Solve an error Sender mismatch
In the SMTP protocol (Simple Mail Transfer Protocol), the header From
specifies the email address of the sender of the message. 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 the same address when sending the message. The method setFrom
also defines the field Reply-To
from the e-mail.
Error Sender mismatch SMTP code: 550 Additional SMTP info: 5.7.1
thus occurs when the email address specified in the field setFrom
does not match the email address specified in the header From
when sending the message.
To avoid this error:
Instead of using the method
setFrom
to set the sender's email address, use the propertyFrom
of the PHPMailer object, example:$mail = new PHPMailer(); $mail->From = 'expediteur@domain.xyz';
Make sure that the value specified in the property
From
corresponds exactly to the email address used in the fieldsetFrom
.Example, if you use
setFrom
with a sender name like this:$mail->setFrom('expediteur@domain.xyz', 'Nom Expediteur');
... then make sure that the value of
From
is also defined with the sender name:$mail->From = 'expediteur@domain.xyz'; $mail->FromName = 'Nom Expediteur';
Then continue setting up and sending the e-mail normally.