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:

  1. Click here to download the PHPMailer library.
  2. Copy the files to a directory on your website via FTP.
  3. Link your script to PHPMailer, example (replace xxxx with 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:

  1. Instead of using the setFrom method to set the sender's email address, use the From property of the PHPMailer object, example:

    $mail = new PHPMailer();
    $mail->From = 'sender@domain.xyz';
  2. Make sure the value specified in the From property matches exactly the email address used in the setFrom field.

    Example, if you use setFrom with a sender's name like this:

    $mail->setFrom('sender@domain.xyz', 'From Name');

    … then make sure that the value of From is 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


Has this FAQ been helpful?