Knowledge base
1000 FAQs, 500 tutorials and instructional 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 you to send HTML-formatted emails from a website.
- This library, in particular, supports attachments and SMTP authentication, as well as 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 (replace
xxxxwith the path to the tool):require_once('xxxx/class.phpmailer.php');
Resolve a Sender mismatch error
In the SMTP (Simple Mail Transfer Protocol) protocol, the From header 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 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 = 'sender@domain.xyz';Make sure the value specified in the
Fromproperty matches exactly the email address used in thesetFromfield.Example, if you use
setFromwith a sender's name like this:$mail->setFrom('sender@domain.xyz', 'From Name');… then make sure that the value of
Fromis also set with the sender's name:$mail->From = 'sender@domain.xyz'; $mail->FromName = 'From Name';
Then, continue the configuration and sending of the email as usual.
Learn more
Link to this FAQ:
Has this FAQ been helpful?