robrodp
asked on
Cant set the from address in my linux (WHM) server
I dont know what happened
Using PHPmailer 5.2.0
I cant set the from address in my emails: (I could last week)
No matter what $sender has it forces the from to be the Username. I think it is a server issue but cant figure out what
Any ideas?
Roberto
Using PHPmailer 5.2.0
I cant set the from address in my emails: (I could last week)
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = $sec;
$mail->SMTPDebug = 2;
$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent
$mail->Host = $smtp; // sets the SMTP server
$mail->Port = $port; // set the SMTP port for the GMAIL server
$mail->Username = $usuario; // SMTP account username
$mail->Password = $pass; // SMTP account password
$mail->AddReplyTo ($replyto);
$mail->SetFrom ($sender,"Admin");
No matter what $sender has it forces the from to be the Username. I think it is a server issue but cant figure out what
Any ideas?
Roberto
First up: update your PHPMailer to the latest version NOW. The version you're using is buggy, vulnerable, and many years out of date.
Most large ISPs, gmail especially, specifically combat email forgery by only allowing users to send using their account addresses (Username) as both the from address and the envelope sender address, and this is likely what's happening to you. If you want to send using some other from address, first you need a mail server that will allow you to do so, then you need to be sure that your mail source is permitted to use that address in SPF settings for the domain.
The only halfway workaround is to put your desired from address into a reply-to header (using PHPMailer's addReplyTo() method), which will at least make replies go to the right place.
This is an ISP limitation, not a PHPMailer issue.
Most large ISPs, gmail especially, specifically combat email forgery by only allowing users to send using their account addresses (Username) as both the from address and the envelope sender address, and this is likely what's happening to you. If you want to send using some other from address, first you need a mail server that will allow you to do so, then you need to be sure that your mail source is permitted to use that address in SPF settings for the domain.
The only halfway workaround is to put your desired from address into a reply-to header (using PHPMailer's addReplyTo() method), which will at least make replies go to the right place.
This is an ISP limitation, not a PHPMailer issue.
ASKER
Thx
This PHPmailer.6.0.0 is prettu complicated.
Any simple examples to start off?
Thx
This PHPmailer.6.0.0 is prettu complicated.
Any simple examples to start off?
Thx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thx for the info
1) PHP config - all .ini files used to configure your runtime environment.
2) CMS - WordPress for example, provides hooks to modify PHP mailer config via wp_mail() which any plugin can change.
3) MTA - Your hosting company may have forcibly changed your MTA settings, if your site was flagged as sending spam.
4) External Service - If you're using a service like SendGrid or MailGun, using port 587 authenticated submission, then your ISP might have added firewall rules which are blocking your email sending.
For 1-3, check your MTA logs.
For 4, use tshark.
I always start debugging this type of client problem using the command line swaks tool from my home office, if an external service is being used.