How to set SMTP details in script? - php

As e-mails sent from my website usually go into Junk, I wanted to edit php.ini file to fix it, but it is not allowed by my hosting provider. They offered their own solution for this:
The solution we can offer you is to use SMTP for your mailservice.
You can do that by setting any script you are using to SMTP service
with the below details:
Incoming mailserver: mail.website.com
Outgoing mailserver: mail.website.com
Username: email account set with your domain
Password: your email account password.
I do have couple of .php scripts that send e-mails, but I don't know how to edit SMTP details in them. So how would I do that?
Thank You ))

You should try to use PHPMailer for sending the mails. You will get it here at:
http://phpmailer.worxware.com/
Advanced setup configuration for SMTP can be configured from the script itself if you are using PHPMailer. Detailed guide can be found here:
http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/

Related

External SMTP setup on Azure

I have a website on Azure Web Apps and want to enable SMTP settings to be able to receive emails through my websites contact form. One of the solutions that I found on this forum were to use an external SMTP. I went over to my web root and modified the php.ini file, changing the default SMTP settings to the external SMTP I want to use. I changed the SMTP server name and the port number.
However, that does not suffice. I need to provide credentials for SMTP relay, and I don't understand how SMTP authentication comes into play here. I am currently using the mail function in my HTML form with PHP handling.
If someone could please guide me on the process, I'd be highly grateful.
Actually, on Azure, you don't need to use External SMTP server to send emails in your app. You can easily use SendGrid to satisfy this.
Here is a detailed guide on how to use the SendGrid email service from PHP: https://azure.microsoft.com/en-us/documentation/articles/store-sendgrid-php-how-to-send-email/.

Laravel 4 Mail - failed SMTP on server, switching to mail method

This is quite strange as email sending using my Gmail SMTP server works in my localhost, but when I deployed it on a VPS, it wouldn't work at all.
I can't find any issue as to why this is happening, the configuration looks normal (SSL port 465, Gmail SMTP server). I'm using Laravel 4.0.9 so I thought of upgrading to 4.1/4.2 to use the Mailgun feature (not sure if 4.0 can use Mailgun?)
Anyway, for a quick fix, I just switched to mail method for email sending. Since this works well for me, my question is that whether there is any tradeoff of using mail instead of SMTP on Laravel? The delivery seems okay as it got to my inbox, but what about the long term?
Any thoughts would be very much appreciated :)
When using the built-in mail function you don't benefit from additional features such as DKIM and the SFP configuration for your domain may not allow hosts other than your SMTP mail server to send mail for your domain, all of this makes the mail you send that way look like spam to other servers.
While you may not have issues with some providers, try to send mail to some more restrictive providers such as Outlook (ex-Hotmail); I'm pretty sure all the mail you send there will be automatically marked as spam because of the issues described above.
PHP mail may be faster since you don't have to connect to your smtp server, but it's not better. In the long run, SMTP email is the only way to guarantee that your email will arrive in the inbox of your receivers

ASP.NET MVC3 C# send email like in PHP

I have question about sending emails from MVC3 application. I already read for exmple about ActionMailer.Net, I have seen a lot of forums and helpers from someone. Everywhere I saw SMTP server and its settings, for example in Web.config, or in appropriate method/function. Is it possible to send email without smtp settings? I am building application, which will be used by several users, I dont want to put them to need setting some SMTP...
I need to send emails like "Your password is xxxx, go to www.mysite.com, thank you." and so on. I dont need to have it in any mailbox (as history), I dont want reply for it.
Is there a possibility like in php where I use mail(...) function, without setting SMTP server, I can send from -> to what ever I want.
So am I bad understanding to something. Pleas help me to figue this out. Thank you very much
You have to have an SMTP server, otherwise you can't send mail via SMTP. The same is true with PHP.
Whether you need to have the settings depends greatly on your hosting. Most servers will have the SMTP stuff set up in a config file higher up the chain, so often you can leave the settings at their default, and ASP.Net will still be able to send mail using SMTP with no specific settings being necessary.
However, its also possible that your host will require you to use specific SMTP settings. That's something you'll need to check with the people who will be hosting your site.
If you need example code on how to send an email with minimal code, something like this should work, PROVIDED that your host doesn't want you to specify the settings:
var message = new MailMessage(FROM ADDRESS HERE, TO ADDRESS HERE)
{
Subject = "Please confirm your email",
Body = "PUT SOME BODY COPY HERE"
};
var client = new SmtpClient();
client.Send(message);
Is it possible to send email without smtp settings?
Of course that it is not possible. You cannot send an email without an SMTP server. This simply doesn't make sense.
It is possible to send mails without SMTP server directly through your code, i had already did this, but later after some months mail guard kind of things started to blocking my IP.
just read this blog.;)

Sending email in html format

Hi I am configuring a Joomla Application for sending emails using gmail smtp server. I used it on my localhost and found to work correctly. But its not working on my remote host server. I am using the same settings for it. Can anyone reply me the problem. Its says that email could not be sent
Did you sent bulk mails, news letter and etc ?
if the answer is "yes", you should check your gmail account, because gmail smtp server has a smart bulk spamer recognition engine. so they may deactivated your smtp account because of sending about more than even 50 mails in last 10 mins.
so my suggestion is to forget gmail as your smtp server and start your own smtp server or buy a paid smtp account to do this.

How to send email from local machine to gmail?

I am just learning php and it's my first question on this site. Hope, you will help me. I just want to send Email from my local machine to gmail. I have tried but didn't got any success. Please help How to do this.
my code is
form processing
return mail(
$message['to'],
join("\n", $headers))
};
?>
You will want the mail() function see: php.net/manual/en/function.mail.php
mail('kushagra#gmail.com', 'My First Email', 'The body of my email');
You will need a mail server running on your local machine such as Postfix for *nix or Pegasus for Windows.
If you do not have the ability run a mail server on your machine then you might need to use a PHP class that allows you to connect to an SMTP server such as SwiftMailer or PHPMailer.
Be aware though that a lot of ISPs will block connections on port 25 (SMTP) to protect against spamming (see my encounter of this with Optus a few years ago http://blog.simonholywell.com/post/374223466/optus-cable-port-25-smtp). If they are blocking it then you will need to use their SMTP server.
There is a tool linked in my blog post above which will allow you to determine if it is blocked or not see: http://www.zoneedit.com/smtp.html
The standard builtin function to send mail in PHP is mail():
http://php.net/mail
Unfortunately, you cannot use it with Gmail since Gmail requires two security measures that are not supported by good old mail():
Authentication
Encryption
You need to find and download a third-party library. Popular choices include PHPMailer and Swift Mailer.
If you take a look at this PHPMailer example you could use Gmail as an SMTP server to send mail to your own account - guaranteed delivery!

Categories