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.
PHPMailer
PHPMailer is a library for sending emails from a website in HTML format. It supports attachments, SMTP authentication, and multipart/alternative for clients that cannot read HTML emails.
Using PHPMailer
To use PHPMailer, you need to install it manually:
- Download the PHPMailer library: https://github.com/PHPMailer/PHPMailer
- Copy the files to a directory on your website via FTP
- Link your script to PHPMailer. Example:
require_once('path_to_modify/class.phpmailer.php');
Fixing a Sender Mismatch Error
In the SMTP (Simple Mail Transfer Protocol) protocol, the "From" header specifies the sender's email address. 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 the 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, you need to replace the 'setFrom' field with 'From' when configuring PHPMailer:
- Instead of using the 'setFrom' method to set the sender's email address, use the 'From' property of the PHPMailer object. For example:
$mail = new PHPMailer();
$mail->From = 'sender@example.com'; - Ensure that the value specified in the 'From' property exactly matches the email address used in the 'setFrom' field. For example, if you use 'setFrom' with a sender name like this:
$mail->setFrom('sender@example.com', 'Sender Name');then make sure that the value of 'From' is also set with the sender name:
$mail->From = 'sender@example.com';
$mail->FromName = 'Sender Name';
After that, continue configuring and sending the email as usual.
Learn More
- Authenticated Mail (SMTP) from a Website
- Unauthenticated Mail via PHP mail()
- Manually Configure Your Emails, Contacts, and Calendars on Your Devices